解决方案 »

  1.   

    最好给出简单的建表语句以及简单的数据,这样别人帮你写就好点。
    或者你去SQL区提问。
      

  2.   

    http://www.cnblogs.com/smhy8187/articles/677742.html
      

  3.   

    最好给出具体的表结构和测试数据以及期望的结果,然后去SQL区提问= =
      

  4.   

    CREATE  proc ProcBlacker_ADD                   --定义存储过程
    @UserID int,                                              --用户输入的参数1                 
    @strName varchar(20),                               --用户输入的参数2   
    @strMobile varchar(20),                              --用户输入的参数3  
    @strRe nvarchar(200)                          --用户输入的参数4,最后一个不需要加,  asdeclare @ID int                                                  --定义变量
    declare @Account varchar(50)                             --同上
    declare @Content  varchar(50)        --同上 if not exists(select * from tblBlackList(nolock)      --如果不存在则执行下面的语句.
    where  fdcMobile=@strMobile)
    begin
    insert into tblBlackList(fdcMobile,fdcName,fdtTm,fdcMemo)
    values(@strMobile,@strName,getdate(),@strRe)      --getdate()获取当前系统的时间   
    set @ID=@@identity                --返回一行记录 select @Account=Account from dbo.UserInfo where UserID=@UserID
    set  @Content='添加黑名单('+'操作者:'+@Account+','+'用户名:'+@strName+'手机:'+@strMobile+'备注:'+@strRe+')'    --设置变量的值
    exec ProcRecordLog  @Account,'添加',@Content                       ---执行储过程ProcRecordLog return @ID                      
    end
    GO