General information
Category:
Database DAO/RDO/ODBC/ADO
>Hello everyone,
>
>
>Is it possible to INSERT data and retrieve the new @@IDENTITY in one single instruction With ADO connection and SQLServer
>
>Ex:
>
>Connection.execute " INSERT INTO MyTable (MyField) VALUES ('Myvalue')
> SELECT @@IDENTITY AS 'MyIdentity' "
>
>MyNewIdentity = 'MyIdentity'
>
>
>Tanks
>
>Louis-André Morin
Besides what Eric suggested, you can also create a stored procedure with an output parameter that returns the new identity value. The difference is that you need to use an ADO command object with parameters to call such a stored procedure. The advantage is that the stored procedure runs faster and scales better.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only