INSERT INTO dbo.UV_SERIAL VALUES('a')
SELECT 'AP' + CAST(SCOPE_IDENTITY() AS char(10))
利用SCOPE_IDENTITY()产生唯一ID
ALTER PROCEDURE [dbo].[UP_UV_GET_SEQUENCE] @i_type varchar(2), @o_id varchar(12) output --@i_type 是统一视图的对象类型, 可能是 UR(用户), OR(组织),GR(组)
AS BEGIN
DECLARE @cnt int
SELECT @cnt=@@trancount
IF ( @cnt=0 ) BEGIN TRAN UV_GET_SEQUENCE
ELSE SAVE TRAN UV_GET_SEQUENCE
INSERT INTO UV_SERIAL VALUES('a')
SELECT @o_id=@i_type + CAST(SCOPE_IDENTITY() AS char(10))
ROLLBACK TRAN UV_GET_SEQUENCE
END