 |
| SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 4th, 2004, 10:33 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Problem to run delete and exec DTS in Stored Proc
Hi,
I have encountered some problem in using stored procedure and DTS package.actually i need to update the particular set of records in DB. I use the stored procedure to do the records deletion and then insert the new records using the DTS package. FYI, i am using the stored procedure as well to call the DTS package. however it can not be run, and hang over there till i need to manually kill the sql process in task manager. The command that i use inside the stored procedure are DELETE and EXEC. Is there any priority of execution between these 2 commands? because i found out that the deletion have not complete but the DTS package is starting to run. additional info, i am using transaction as well so that the data will stil remain unchanged if any error occur.
Thanks in advance!
Jimmy
Jimmy
|
|

July 5th, 2004, 08:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hello,
How are you calling the stored procedure? In the DTS package, through an application? In addition, how are you calling the DTS package? Through VB code (SQL DTS objects), by scheduling, or by dtsrun in the stored procedure?
Thanks,
Brian
|
|

July 5th, 2004, 12:54 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
HI Brian,
Thanks for reply.
Well, i am calling the stored procedure through VB code while the DTS package is called using the same stored procedure by DTSRUN.
Jimmy
|
|

July 6th, 2004, 06:51 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hello,
OK. You have to make sure that the account executing the stored procedure has permissions. In addition, that account must also have permissions to execute xp_cmdShell; that is what you are using, correct?
Are you using a SQL login or Integrated security to login with?
Brian
|
|

July 7th, 2004, 09:14 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
 Why not do updates rather than a delete and insert?
 If you are not able to use updates, why not use a delete in an "Execute SQL" task in the DTS package. That way you can make sure the delete is committed before starting the inserts. And it can be done on the same connection, which might help your task complete.
Hope this helps!
Jeff
|
|

July 8th, 2004, 09:12 PM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Thanks jbelina.
I will try out your sugggestion.
BTW, I manage to solve the problem. It is all because of the TRANSACTION where it happens to have implicit and explicit transaction. FYI, explicit transaction is all we declare as BEGIN TRANSACTION while the implicit is usually occurred during we use DELETE, SELECT, UPDATE...and we need to commit the implicit trasaction first.
:)
Jimmy
|
|

July 12th, 2004, 04:13 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi All,
Problem again!! :(
I found out the stored procedure that i written can not rollback the records after when i purposely test out the rollback function especially during the calling DTS package.
Attach is the stored procedure and hope someone could help me to solve the problems!!
Thanks.
BEGIN TRANSACTION
SAVE TRANSACTION MY_TRAN
-- ====================================
-- Start Performing Records Deleting
-- ====================================
SELECT @sPassValue=@sValueFromVB -- Implicit Transaction
COMMIT TRANSACTION
EXEC @hr = sp_CallDeleteRecords @sPassValue -- Call stored procedure
IF @hr <> 0
BEGIN
GOTO E_OAError
END
-- ================================
-- Run DTS Package
-- ================================
-- create a package object
EXEC @hr = sp_OACreate 'DTS.Package', @object OUTPUT
if @hr <> 0
BEGIN
GOTO E_OAError
END
-- Load package object
EXEC @hr = sp_OAMethod @object, 'LoadFromSQLServer ("SERVERNAME", "user", "password", 256, "packagePassword", , , "packageName")',NULL
IF @hr <> 0
BEGIN
GOTO E_OAError
END
-- Execute package object
EXEC @hr = sp_OAMethod @object, 'Execute'
IF @hr <> 0
BEGIN
GOTO E_OAError
END
CleanUp:
RETURN
E_OAError:
ROLLBACK TRANSACTION MY_TRAN
exec dbo.dt_displayoaerror_u @object, @hr
GOTO CleanUp
COMMIT TRANSACTION
p.s. i purposely use another fake server name in DTS calling to test therollback function. however it doesn't rollback the records that have been deleted.
Jimmy
|
|

July 14th, 2004, 10:27 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Jimmy,
I believe your DTS package is being executed on a separate SPID, would it be possible to put all the logic (transaction, delete, update, etc.) in your DTS package?
Take care,
Jeff
|
|
 |