yuniet Posted May 18, 2010 Report Posted May 18, 2010 Hello: I would like to know how can I get in Labview 2009 working with SQL Server database, the id (primary key) of any data once I´ve inserted? Quote
Phillip Brooks Posted May 18, 2010 Report Posted May 18, 2010 Hello: I would like to know how can I get in Labview 2009 working with SQL Server database, the id (primary key) of any data once I´ve inserted? This thread on the NI forums may be of some help. Get generated value of a new dataset Quote
Minh Pham Posted May 19, 2010 Report Posted May 19, 2010 (edited) Hello: I would like to know how can I get in Labview 2009 working with SQL Server database, the id (primary key) of any data once I´ve inserted? im not a database expert but i reckon you can query the Identifier column of that table and sort it in descending order, the 1st item will be the latest identifier that you have just inserted. it will b something like: SELECT TOP 1 Identifier FROM Mytable ORDER BY DESC Or you can just Google for a built-in function that returns the latest ID Regards, Edited May 19, 2010 by Minh Pham 1 Quote
MikaelH Posted May 19, 2010 Report Posted May 19, 2010 To be sure you get the right Identity/ID/Identifier of a recently inserted row, you should call execute this query: MSSQL: SELECT SCOPE_IDENTITY() do not use the SELECT @@IDENTITY command it can give you unwanted behavior. http://msdn.microsoft.com/en-us/library/ms190315.aspx MYSQL: SELECT LAST_INSERT_ID() Cheers, Mikael 1 Quote
yuniet Posted May 19, 2010 Author Report Posted May 19, 2010 im not a database expert but i reckon you can query the Identifier column of that table and sort it in descending order, the 1st item will be the latest identifier that you have just inserted. it will b something like: SELECT TOP 1 Identifier FROM Mytable ORDER BY DESC Or you can just Google for a built-in function that returns the latest ID Regards, Actually I had found that solution yesterday night, jejeje and it worked perfectly, anyway thanks for your fast collaboration To be sure you get the right Identity/ID/Identifier of a recently inserted row, you should call execute this query: MSSQL: SELECT SCOPE_IDENTITY() do not use the SELECT @@IDENTITY command it can give you unwanted behavior. http://msdn.microsof...y/ms190315.aspx MYSQL: SELECT LAST_INSERT_ID() Cheers, Mikael So help ful mikael, it made me clear some things, yesterday I was trying with SELECT LAST_INSERT_ID() but working with MSSQL : ) regards Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.