最后使用了这个脚本
DECLARE @Product_ID INT
DECLARE Product CURSOR
FOR SELECT Product_ID
FROM dbo.table
OPEN Product
declare @Paths varchar(128) ,
@FileName varchar(128),
@FileExtension varchar(128)
FETCH NEXT FROM Product
INTO @Product_ID
WHILE @@FETCH_STATUS = 0
BEGIN
select @Paths = 'C:\Data\xmls\' ,
@FileExtension = '.xml',
@FileName = @Product_ID
declare @objFSys int
declare @i int
declare @File varchar(1000)
select @File = @Paths + @FileName + @FileExtension
exec sp_OACreate 'Scripting.FileSystemObject', @objFSys out
exec sp_OAMethod @objFSys, 'FileExists', @i out, @File
if @i = 1
print 'Allready There ' + CONVERT(VARCHAR(36), @Product_ID)
else
PRINT 'Neet to get ' + CONVERT(VARCHAR(36), @Product_ID) + '.xml From Source.'
FETCH NEXT FROM Product
INTO @Product_ID
exec sp_OADestroy @objFSys
END
CLOSE Product
DEALLOCATE Product