Opps... there was an END missing in there... here is the corrected.
Here is an sp_NewID():
CREATE PROC sp_NewID
@basetablename varchar(30) = 'default'
AS
Declare @returnNewID int
BEGIN TRANSACTION NewID
SELECT @basetablename = LOWER( (at) basetablename)
IF NOT EXISTS (SELECT * FROM sy_uniqueid WHERE sy_uniqueid .DOT tablename = @basetablename) BEGIN INSERT INTO sy_uniqueid VALUES (@basetablename ,0) END
Update sy_uniqueid SET last_id = last_id + 1 , (at) returnNewID = last_id WHERE sy_uniqueid .DOT tablename = @basetablename
COMMIT TRANSACTION NewID
Return @returnNewID
***************** BOb </font></i>
©2001 Bob Archer |