|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
gettting list of @@IDENTITYi am sending to a SP values
which insetred into a table (1 or more rows) how can i return from a stored procedure this list of ID's? thnaks i nadvance peleg You can in the proc create a temporary table or a table variable and after each INSERT you insert
the generated value into this table. And before you exist the procedure you do SELECT form this table. -- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi "pelegk1" <pele***@discussions.microsoft.com> wrote in message news:A74EE81C-020C-4432-A2AB-67ECB1A72757@microsoft.com... >i am sending to a SP values > which insetred into a table (1 or more rows) > how can i return from a stored procedure this list of ID's? > > thnaks i nadvance > peleg i cant do it after each insert beacuse i do
insert into table1...... select id,1,......... any other idea? Show quote "Tibor Karaszi" wrote: > You can in the proc create a temporary table or a table variable and after each INSERT you insert > the generated value into this table. And before you exist the procedure you do SELECT form this > table. > > -- > Tibor Karaszi, SQL Server MVP > http://www.karaszi.com/sqlserver/default.asp > http://sqlblog.com/blogs/tibor_karaszi > > > "pelegk1" <pele***@discussions.microsoft.com> wrote in message > news:A74EE81C-020C-4432-A2AB-67ECB1A72757@microsoft.com... > >i am sending to a SP values > > which insetred into a table (1 or more rows) > > how can i return from a stored procedure this list of ID's? > > > > thnaks i nadvance > > peleg > If you use SQL 2005, have a look at the OUTPUT Clause
Ulrich Show quote "pelegk1" <pele***@discussions.microsoft.com> wrote in message news:01008580-402E-4DF0-9E7F-A009AD7B45CB@microsoft.com... >i cant do it after each insert beacuse i do > insert into table1...... > select id,1,......... > > any other idea? know how to get all the id's that created from the insert
but how if i make a string of them i can return it to the user? Show quote "Ulrich" wrote: > If you use SQL 2005, have a look at the OUTPUT Clause > > Ulrich > > "pelegk1" <pele***@discussions.microsoft.com> wrote in message > news:01008580-402E-4DF0-9E7F-A009AD7B45CB@microsoft.com... > >i cant do it after each insert beacuse i do > > insert into table1...... > > select id,1,......... > > > > any other idea? > > > > See my original reply. Push the values into a table and at the end of the proc just do a SELECT from
that table. Your procedure will return a resultset with all the generated ids. -- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://sqlblog.com/blogs/tibor_karaszi "pelegk1" <pele***@discussions.microsoft.com> wrote in message news:98D1D6A6-7882-4BD0-BB7F-6F3652DD1D0A@microsoft.com... > know how to get all the id's that created from the insert > but how if i make a string of them i can return it to the user? > > "Ulrich" wrote: > >> If you use SQL 2005, have a look at the OUTPUT Clause >> >> Ulrich >> >> "pelegk1" <pele***@discussions.microsoft.com> wrote in message >> news:01008580-402E-4DF0-9E7F-A009AD7B45CB@microsoft.com... >> >i cant do it after each insert beacuse i do >> > insert into table1...... >> > select id,1,......... >> > >> > any other idea? >> >> >> >> |
|||||||||||||||||||||||