Is there a way to get the last inserted id if I use SQL Server CE? I have 2 tables, and when a new record is created, I also want to save the identifier in the second table.
I hope this example helps you.
INSERT INTO jobs (job_desc,min_level,max_level) VALUES ('A new job', 25, 100); SELECT job_id FROM jobs WHERE job_id = @@IDENTITY;
SELECT @@IDENTITY
will retrieve the last automatically generated authentication value in SQL Server.
Assuming higher id values ββare always newer, how about:
id
SELECT TOP 1 id FROM your_table ORDER BY id DESC
or
SELECT MAX(id) FROM your_table
use this query:
INSERT INTO Persons (FirstName) VALUES ('Joe'); SELECT ID AS LastID FROM Persons WHERE ID = @@Identity;
or you can view this link for more information: http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of -record /
It worked great for me
SELECT TOP (1) your_id FROM your_table ORDER BY your_id DESC
Source: https://habr.com/ru/post/1391528/More articles:Choosing jqTransform - Ajax update? - javascriptThe application works on the device through direct installation, but not through ipa - iostwo shorts added together are not equal short? - c #Correct orientation prevention in Flex Mobile app - flexWhy is ff still storing data in RAM? - memory-managementDownloading ffdf data takes up a lot of memory - rNSUserDefaults written in -applicationWillTerminate: do not take effect; What for? - iosLINQ find records without connection - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1391532/how-a-threaded-server-continues-to-listen-on-the-post-for-more-incoming-connections&usg=ALkJrhgXIq-xZST_4wqT5OeQJvlDSOeS-gWhat design model am I using? - design-patternsAll Articles