Last embed UNIQUEIDENTIFIER in SQL Server 2000

The OUTPUT clause is compatible with SQL Server 2005, but not with SQL Server 2000.

How do I convert this command to work in SQL Server 2000?

 CREATE TABLE sample ( ID uniqueidentifier NOT NULL DEFAULT newid(), Title varchar(30) NOT NULL ) INSERT INTO sample (Title) OUTPUT INSERTED.ID VALUES ('Test1') 

I need a command to get the identifier, since the INSERT must be called from a stored procedure.

Thanks for any help!

+6
source share
1 answer
 DECLARE @uid uniqueidentifier SET @uid = newid() INSERT INTO sample (ID, Title) VALUES (@uid,'Test1') SELECT @uid AS ID 
+11
source

Source: https://habr.com/ru/post/887150/


All Articles