首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

sql存储过程有关问题,帮小弟我

2012-07-28 
sql存储过程问题,帮我啊set ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER PROCEDURE [dbo].[getUserName

sql存储过程问题,帮我啊
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[getUserNamebb]
  @UserName varchar(100),
  @paww varchar(100),
@biaoshu varchar(100)
  as
  begin
declare @cishu int,@mon int,@uuid int,@StartTime datetime
set @uuid=0;
set @StartTime =(select getdate())

  select top 1 pe_pwdd,pe_sex,pe_nini,diqu1,diqu2,pe_UserId,addtime,pe_zhuye,pe_cishu
  from dbo.[useruser1] 
  where pe_email=@UserName and pe_pwdd=@paww
if @@rowcount>0
begin

select top 1 @uuid=pe_UserId
  from dbo.[useruser1] 
  where pe_email=@UserName and pe_pwdd=@paww
update useruser1 set pe_cishu=pe_cishu+1,zuihoutime=@StartTime where pe_userid=@uuid
exec('Select pe_jibie,pe_zeou,pe_Photo,pe_nianji,pe_zhuye,pe_zhaopian From ' + @biaoshu + ' Where pe_UserId=@uuid')
 
end 
else
return 1
  end
创建没一点问题,但是执行的时候,给上参数,就会提示


(1 行受影响)

(1 行受影响)
消息 137,级别 15,状态 2,第 1 行
必须声明标量变量 "@uuid"。

(1 行受影响)


为什么啊,大侠帮我

[解决办法]

SQL code
ALTER PROCEDURE [dbo].[getUserNamebb]    @UserName varchar(100),    @paww varchar(100),    @biaoshu varchar(100)asbegin    declare @cishu int,@mon int,@uuid int,@StartTime datetime    set @uuid=0;    set @StartTime =(select getdate())    select top 1 pe_pwdd,pe_sex,pe_nini,diqu1,diqu2,pe_UserId,addtime,pe_zhuye,pe_cishu    from dbo.[useruser1]      where pe_email=@UserName and pe_pwdd=@paww    if @@rowcount>0    begin        select top 1 @uuid=pe_UserId          from dbo.[useruser1]            where pe_email=@UserName and pe_pwdd=@paww                  update useruser1 set pe_cishu=pe_cishu+1,zuihoutime=@StartTime where pe_userid=@uuid                declare @strSql nvarchar(2048)        set @strSql = 'Select pe_jibie,pe_zeou,pe_Photo,pe_nianji,pe_zhuye,pe_zhaopian From ' + @biaoshu + ' Where pe_UserId=@uuid'        execute sp_executesql @strSql,N'@uuid int',@uuid    end       else    return 1end
[解决办法]
探讨
啊,两位老大的答案都是正确的,能告诉我

set @strSql = 'Select pe_jibie,pe_zeou,pe_Photo,pe_nianji,pe_zhuye,pe_zhaopian From ' + @biaoshu + ' Where pe_UserId=@uuid'

execute sp_executesql @strSql,N'@uuid int',@uuid……

热点排行