@@identity的使用
-- ============================================= -- Author: Qiuhua,Huang -- Create date: 08/09/2012 -- Description: insert into tabel of "call" -- ============================================= --pro_insertCall 1958,\'20\',0,0,\'22333\',2,\'2012-05-03\',\'2012-02-03\',0 ALTER PROCEDURE [dbo].[pro_insertCall] @shopId int, @callerID varchar(200),--callerName @callstatus int=0, @callcategory int, @callcontent varchar(1000), @adduser int, @calldatetime varchar(50), @addtime varchar(50), @toptradeID int AS BEGIN declare @insertSQL VARCHAR(4000) set @insertSQL=\' insert into [call]( shopID, callerID, callstatus, calldatetime, callcategory, callContent, adduser, addtime, IPTime, completeTime, etatime, toptradeID, DateRev) values(\' +Convert(varchar,@shopId)+\',\' +\'\'\'\'+@callerID+\'\'\',\' +Convert(varchar,@callstatus )+\',\'\'\' +@calldatetime+\'\'\',\' +Convert(varchar,@callcategory )+\',\' +\'\'\'\'+@callcontent +\'\'\'\'+\',\' +Convert(varchar,@adduser)+\',\'\'\' +@addtime+\'\'\',\'+ +\'null\'+\',\' +\'null\'+\',\' +\'null\'+\',\' +Convert(varchar,@toptradeID)+\',\' +\'null\'+\')\' print @insertSQL exec(@insertSQL) declare @callrequestnum varchar(20) declare @id int --查询刚插入记录的id set @id = (select top 1 @@identity from dbo.call) set @callrequestnum = convert(varchar,@id+1000) update dbo.call set callrequestnum=@callrequestnum where id=@id END
版权声明:本文为come-on-come-on原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。