标签:
?
?
CREATE TABLE dbo.GlobalSequence
(
id INT IDENTITY(1, 1)
)
GO
?
?
CREATE PROC seq ( @id INT OUTPUT )
AS
BEGIN
BEGIN TRAN
DECLARE @NewSequenceValue TABLE ( ID INT );
?
INSERT INTO dbo.GlobalSequence
OUTPUT inserted.id
INTO @NewSequenceValue
DEFAULT VALUES
?
ROLLBACK TRAN
SELECT @id = id
FROM @NewSequenceValue
?
?
END
?
-- test
DECLARE @id INT
EXEC seq @id OUTPUT
SELECT @id
标签:
原文地址:http://www.cnblogs.com/QinQouShui/p/4320569.html