Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GETAUTOINCVALUE for sqlserver
Message
 
 
To
07/12/2009 11:03:07
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01437880
Message ID:
01437895
Views:
43
>>>Is there any equivalent function (GETAUTOINCVALUE) to get the autoinc value in MS SQL SERVER ?
>>
>>Yes, SCOPE_IDENTITY() function.
>>
>>In SQL Server 2005 and up the best method would be to use OUTPUT clause of the INSERT command to get the new ID.
>Thanks Naomi. Can you please give me an example how to pass the OUTPUT cause?
declare @Output table (ID int)

insert into myTable (field1, field2) OUTPUT Inserted.Id INTO @Output values (@Param1, @Param2)

select * from @Output
or the same without a table variable.

See http://technet.microsoft.com/en-us/library/ms177564.aspx
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform