Solved

simple : insert row then set parameter to scope_identity

Posted on 2009-07-16
1
1,156 Views
Last Modified: 2013-11-10
im trying to insert a new row inside an execute sql task and store the scope_identity() into a variable, this is proving harder than I would have thought.

I have amanged to store it to a result set by doing

Insert into &.. ;
Select scope_identity();

 But then I have to use a loop to get the individual column from the result set, I dont like doing this because I only have one row so seems silly to loop through one row..

If you have any ideas, it would be appreciated.
0
Comment
Question by:crazyman
1 Comment
 
LVL 22

Accepted Solution

by:
PedroCGD earned 500 total points
ID: 24867772
use an output parameter inside a stored procedure to send the identity to a SSIS variable...
need an example?!

Helped?
Regards,
Pedro
www.pedrocgd.blogspot.com
www.BIResort.net
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now