Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Get row ID from INSERT DTS

Author  Topic 

okrocker
Starting Member

3 Posts

Posted - 2008-02-08 : 10:25:17
I'm developing a DTS package in SQLserver 2000. I have several data pumps, AX script task, SQL task, even muli-path decision script task.

My problem is one SQL task where I INSERT a record with data I've assembled from Global variables. The record is inserted correctly but I'm not getting the row ID returned as an output parameter which I have assigned to a Global variable. It's blank!

INSERT INTO MyTable([name], phone, fax, email)
VALUES(?,?,?,?)
SELECT @@Identity AS ident

I've also tried SCOPE_IDENTITY()...

Of course then ident is assigned as a Row Value Output parameter.

******UPDATE*****
INSERT INTO MyTable([name], phone, fax, email)
VALUES('john','123-6321','123-5321','john@place.com')
;
SELECT ident FROM MyTable
WHERE [name] = 'john' AND email = 'john@place.com'

I've simplified the INSERT code...taking out all the Global variables on the input side. Still no luck. Even tried a separate SELECT instead.

Looks to me like once the SQL task is set to INSERT, that's all it will do. Has anyone run into this?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-08 : 13:43:09
You are executing this in DTS itself? can you create a procedure with an OUTPUT parameter and out this code to it. Call procedure from DTS and the try to get returned value to variable in DTS.
Go to Top of Page

okrocker
Starting Member

3 Posts

Posted - 2008-02-11 : 09:36:38
Well I'm doing everything else in this DTS package & hate to go out just for this one minor problem...there must be a way! Besides I'd have to pass all the input variables out to a usp & get the output back...
Go to Top of Page
   

- Advertisement -