Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从后端获取最后插入记录的 Id 并显示与成功消息相同的成功消息,如“RECORD INSERTED SUCCESSFULLY AS”+Id in flex ...我正在使用 Toad for sql server.......
如果您使用的是 SQL Server 2005 或 2008,请使用 function SCOPE_IDENTITY(),否则使用 variable @@IDENTITY。例如,如果您有一个具有自动递增列id和列值的表:
SCOPE_IDENTITY()
@@IDENTITY
DECLARE @newid int INSERT INTO mytable (value) VALUES 'x' SET @newid = SCOPE_IDENTITY() SELECT @newid