OUTPUT子句与sql Server 2005兼容,但不兼容sql Server 2000.
如何将此命令转换为在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')
我需要命令来检索ID,因为需要从存储过程调用INSERT命令.
谢谢你的帮助!
解决方法
DECLARE @uid uniqueidentifier SET @uid = newid() INSERT INTO sample (ID,Title) VALUES (@uid,'Test1') SELECT @uid AS ID