Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GETAUTOINCVALUE for sqlserver
Message
 
 
À
07/12/2009 11:03:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01437880
Message ID:
01437895
Vues:
42
>>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform