Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GETAUTOINCVALUE for sqlserver
Message
De
07/12/2009 12:05:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/12/2009 10:45:25
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:
01437918
Vues:
76
This message has been marked as a message which has helped to the initial question of the thread.
>Is there any equivalent function (GETAUTOINCVALUE) to get the autoinc value in MS SQL SERVER ?

Hi Yiorgos,
How are you doing. I would prefer "OUTPUT" clause because in SQL2008 you can insert multiple rows in one go but functions like scope_identity() return a single scalar value. Here is a sample:
lnHandle = Sqlstringconnect("Driver={SQL Server Native Client 10.0};Server=.\sql2008;Trusted_Connection=yes;Database=test")
TEXT TO lcSQL noshow
CREATE TABLE MyIdTest (
  id INTEGER IDENTITY PRIMARY KEY,
  dummy VARCHAR(100))
ENDTEXT

SQLExec(m.lnHandle, m.lcSQL)

TEXT TO lcInsertMulti noshow
DECLARE @MyTable table( id INTEGER, myvalue varchar(10) );

INSERT MyIdTest (dummy)
 OUTPUT INSERTED.id, INSERTED.dummy INTO @myTable
 VALUES ('AA'),('BB'),('CC')

SELECT * FROM @myTable
ENDTEXT

SQLExec(m.lnHandle, m.lcInsertMulti, 'result')
SQLDisconnect(m.lnHandle)
Select result
Browse
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform