dbTalk Databases Forums  

Return @@IDENTITY from a lookup

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Return @@IDENTITY from a lookup in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
runningdog
 
Posts: n/a

Default Return @@IDENTITY from a lookup - 03-09-2005 , 09:20 PM






For each row of a table I'm transforming I want to write the row to table A
and insert a row in table B and put the value of an identity column on table
B into a column on table A.

I can get a lookup to do the insert into table B but try as I may I can't
get it to return @@IDENTITY.

Lookup looks like

INSERT INTO TableB
(Type)
VALUES ('RA')
SELECT @@IDENTITY AS 'ID'
or SELECT ID FROM TableB WHERE (ID = @@IDENTITY)

Transformation calls lookup with

DTSDestination("ID") = DTSLookUps("LookupB").Execute()
This throws and invalid data type error.

I've tried using EXECUTE to call a stored procedure.
I've tried breaking it into two lookups.
What am I missing?

TIA
Steve





Reply With Quote
  #2  
Old   
runningdog
 
Posts: n/a

Default Re: Return @@IDENTITY from a lookup - 03-09-2005 , 10:31 PM






For anyone struggle with using lookups.
My query generated a double message
(1 row(s) affected)
(1 row(s) affected)
which seems to offend DTS.
inserting the line
SET NOCOUNT ON;
in the beginning of the script fixed it.

"runningdog" <runningdog (AT) reply (DOT) to.newsgroup> wrote

Quote:
For each row of a table I'm transforming I want to write the row to table
A
and insert a row in table B and put the value of an identity column on
table
B into a column on table A.

I can get a lookup to do the insert into table B but try as I may I can't
get it to return @@IDENTITY.

Lookup looks like

INSERT INTO TableB
(Type)
VALUES ('RA')
SELECT @@IDENTITY AS 'ID'
or SELECT ID FROM TableB WHERE (ID = @@IDENTITY)

Transformation calls lookup with

DTSDestination("ID") = DTSLookUps("LookupB").Execute()
This throws and invalid data type error.

I've tried using EXECUTE to call a stored procedure.
I've tried breaking it into two lookups.
What am I missing?

TIA
Steve







Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.