February 12, 2008 at 8:05 am
I'm developing a DTS package in SQLserver 2000. I have a simple problem...or so I thought!
I have an Execute SQL Task;
INSERT INTO MyTable([name], phone, fax, email)
VALUES('john','123-6321','123-5321','john@place.com')
This INSERTs a new record into MyTable.
I also want the row ID of the just inserted record. So I added this code which I've used before in asp pages.
SELECT ID = @@IDENTITY Then I assigned ID to a Global var.
I've also tried SCOPE_IDENTITY() and IDENT_CURRENT().
I've seen this done in 2005 SSIS but I'm not getting anything!
Has anyone run into this?:angry:
********UPDATE*************
I found this same topic on this forum from 2006...
http://www.sqlservercentral.com/Forums/Topic254982-19-1.aspx
Doesn't sound like theres a good way around it...
Microsoft strikes again...
A.S.
MCSE, ASE, DBA
Webmaster
Applications Developer
February 12, 2008 at 10:19 am
you'd need a declare @id int
select @id = scope_identity()
however I'm not sure how you plan on using this in DTS or your Execute SQL task. Maybe if you explain what you want to do, we can help.
February 12, 2008 at 9:48 pm
Heh... one of the many reasons I don't use DTS...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply