码迷,mamicode.com
首页 > 其他好文 > 详细

@@identity的使用

时间:2016-07-11 14:10:25      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

-- =============================================
-- 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

 

@@identity的使用

标签:

原文地址:http://www.cnblogs.com/come-on-come-on/p/5659915.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!