Copy Code code as follows:
CREATE TABLE [dbo]. [Tbguidtable] (
[TableName] [varchar] () not NULL,
[KeyName] [varchar] () not NULL,
[KeyValue] [varchar] (MB) Not NULL
) on [PRIMARY]
Go
if exists (SELECT * from dbo.sysobjects WHERE id = object_id (n ' pcreateguid ') and OBJECTPROPERTY (ID, n ' isprocedure ') = 1)
drop procedure Pcreateguid
Go
------------------------------------
--use: Add a record personal information
--Project Name:
--Description:
--Time: 2011-7-4 15:34:12,2011-08-15
------------------------------------
CREATE PROCEDURE Pcreateguid
@tableName varchar (50),
@keyname varchar (100),
@guid varchar (m) out
As
If not EXISTS (SELECT * from tbguidtable where tablename= @tableName and keyname= @keyname)
Insert into tbguidtable (Tablename,keyname,keyvalue) VALUES (@tableName, @keyname, 10000)
Update tbguidtable set keyvalue=keyvalue+1 where Tablename= @tableName and keyname= @keyname
Select @guid =cast (keyvalue as varchar) from tbguidtable where Tablename= @tableName and keyname= @keyname
Go
---*****---
DECLARE @tableName varchar (50)
DECLARE @keyname varchar (100)
DECLARE @guid varchar (100)
Set @tableName = ' tb1 '
Set @keyname = ' Def '
Execute Pcreateguid @tableName, @keyname, @guid out
Print @guid