-
SP Syntax help - return new identity value as output param
I have a stored proc that will insert a new row into a table
with the values of the parameters you pass in. I need it to
return the value of the ID that's generated by an Identity
column once the row has been written and that value has
been generated. If I just do a SELECT Max(), I could
accidentally grab a row written by someone else, right?
My current sp looks like this:
CREATE PROCEDURE sp_SaveNewLabel
-- @LabelID int output
@LabelType int
, @Logo int
, @Field01 char(30)
AS
INSERT INTO tbLabel
(LabelType
, Logo
, Field01)
VALUES
(@LabelType
, @Logo
, @PrintCC
, @Field01)
How do I grab the new LabelID (the column is int, Identity) and return
it from the stored proc. Any help would be greatly appreciated...
Zack
-
SP Syntax help - return new identity value as output param (reply)
Hi,
You can use the global Variable @@identity to find out the
Last identity number.
After the insert get this value and return it
DP
On 2/4/99 3:12:24 PM, Zack Brown wrote:
> I have a stored proc that will insert a new row into a table
with the
> values of the parameters you pass in. I need it to
return the value of
> the ID that's generated by an Identity
column once the row has been
> written and that value has
been generated. If I just do a SELECT Max(),
> I could
accidentally grab a row written by someone else, right?
My
> current sp looks like this:
CREATE PROCEDURE sp_SaveNewLabel
--
> @LabelID int output
@LabelType int
, @Logo int
, @Field01
> char(30)
AS
INSERT INTO tbLabel
(LabelType
, Logo
,
> Field01)
VALUES
(@LabelType
, @Logo
, @PrintCC
, @Field01)
How
> do I grab the new LabelID (the column is int, Identity) and return
it from
> the stored proc. Any help would be greatly appreciated...
Zack
-
SP Syntax help - return new identity value as output param (reply)
Thanks for the tip, Durga.
One more thing, though. Can you help me with the syntax to return an output parameter?
Thanks,
Zack
On 2/8/99 2:12:01 PM, Durga Prasad Rachapudi wrote:
> Hi,
> You can use the global Variable @@identity to find out the Last
> identity number.
> After the insert get this value and return it
> DP
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|