순차적 글로벌 고유 GUID 생성

1679 단어





USE [BeautySalon]
GO
/******  :  Table [dbo].[SYSSequentialId]     : 08/29/2013 10:38:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SYSSequentialId](
	[RowGuid] [uniqueidentifier] ROWGUIDCOL  NOT NULL CONSTRAINT [DF__SYSGenera__RowGu__045C434E]  DEFAULT (newsequentialid()),
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[HelperId] [tinyint] NOT NULL,
 CONSTRAINT [PK_SYSGenerateId] PRIMARY KEY CLUSTERED 
(
	[RowGuid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
-- ================================================
-- Template generated from Template Explorer using:
-- Create Procedure (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	 GUID  newid() guid
-- =============================================
alter PROCEDURE SYSSequentialId_GetSequentialId
	-- Add the parameters for the stored procedure here
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	INSERT INTO SYSSequentialId(HelperId)VALUES(1)
    SELECT TOP 1 RowGuidCol FROM SYSSequentialId WHERE Id=(SELECT SCOPE_IDENTITY())
END
GO

좋은 웹페이지 즐겨찾기