Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a next number value
Message
From
11/10/2007 06:33:02
 
General information
Forum:
Microsoft SQL Server
Category:
Other
Miscellaneous
Thread ID:
01259689
Message ID:
01260214
Views:
10
Hello Borislav!
In help Transact-SQL :

@@IDENTITY, SCOPE_IDENTITY, and IDENT_CURRENT are similar functions because they all return the last value inserted into the IDENTITY column of a table.
I have chosen first.
Now I try to use SCOPE_IDENTITY() function.

Thank you for answer.

>NEVER use @@IDENTITY, If you have trigger that affect other table that have >IDENTITY field you will get wrong information.
>Use SCOPE_IDENTITY() function instead.
Create PROCEDURE [dbo].[insert_mytable]
       @l_1 int,
       @l_2 varchar(20)
AS
   Insert into cred.dbo.mytable (field1,field2) VALUES (@l_1, @l_2)
   Select SCOPE_IDENTITY() as 'Identity'
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform