Execute DTS from SQL
Hello!
Help to deal with the error:
1. Create an ole object
EXEC @hr = sp_OACreate 'DTS.Package', @oPKG OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @oPKG, @ErrSrc OUT, @ErrDesc OUT
SELECT [Action] = @err_oa_creat, [hr] = convert(varbinary(4),@hr), [Source] = @ErrSrc, [Description] = @ErrDesc
RETURN @hr
END
2. Loading data
through DTS:
DECLARE @ms varchar(255)
SET @ms = 'LoadFromSQLServer("' + 'RU01ST01' + '", "", "", 256, , , , "' + 'LoadSales_RU' + '")'
SELECT @ms
EXEC @hr = sp_OAMethod @oPKG, @ms, NULL
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @oPKG, @ErrSrc OUT, @ErrDesc OUT
SELECT [Action] = @err_oa_load, [hr] = convert(varbinary(4),@hr), [Source] = @ErrSrc, [Description] = @ErrDesc
SELECT @hr
END
EXEC @hr = sp_OAMethod @oPKG, 'Execute'
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @oPKG, @ErrSrc OUT, @ErrDesc OUT
SELECT [Action] = @err_oa_exec, [hr] = convert(varbinary(4),@hr), [Source] = @ErrSrc, [Description] = @ErrDesc
SELECT @hr
END
There is not error and success. However, nothing happens
and no data is loaded.
However, if we run the same
DTS through Sql Server Enterprise Manager (Execute Step),
then all data was successfully loaded.
What could be wrong??
August 16th, 2011 5:45am
Hello!
Thank you for your reply!
Can you duplicate your code, because of the formatting some of the rows of your code
are not visible???
Free Windows Admin Tool Kit Click here and download it now
August 16th, 2011 6:28am
last line
SELECT
@cmd = 'DTSRun /S"' + servername + '" /E /N"' + @package_name + '" '
EXEC @retcode = xp_cmdshell @cmd
Abhinav
August 16th, 2011 6:37am
Abhinav, What do you mean about the:
"
last line....
"
Can you describe this in more detail?
The problem is not solved. I'm waiting for help.
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2012 10:43am