Solved

simple : insert row then set parameter to scope_identity

Posted on 2009-07-16
1
1,160 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Select - column value lookup. 3 40
T-SQL:  Embedding a CTE 5 32
datetime in sql 6 25
SQL - SP needs a little help 9 20
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

911 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

24 Experts available now in Live!

Get 1:1 Help Now