Home All Groups Group Topic Archive Search About

gettting list of @@IDENTITY

Author
1 Sep 2007 5:08 PM
pelegk1
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

Author
1 Sep 2007 5:23 PM
Tibor Karaszi
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 quote
"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
Author
1 Sep 2007 5:32 PM
pelegk1
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
>
Author
1 Sep 2007 6:02 PM
Ulrich
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?
Author
1 Sep 2007 6:38 PM
pelegk1
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?
>
>
>
>
Author
1 Sep 2007 7:39 PM
Tibor Karaszi
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 quote
"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?
>>
>>
>>
>>

AddThis Social Bookmark Button