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

存储过程int参数有关问题

2012-02-02 
存储过程int参数问题CreatePROCEDUREdbo.get_addressbook_by_category@ownerint,@addressCategorynvarchar

存储过程int参数问题
Create   PROCEDURE   dbo.get_addressbook_by_category
@owner   int,
@addressCategory   nvarchar(4000)

as
declare   @sql   varchar(8000)
select   @sql=
'Select  
[ad_id],
[ad_name],
[mobileTelephone],
[birthday],
[sexy],
[units],
[dept],
[address],
[phone],
[province],
[city],
[zip],
[email],
[owner],
[addressCategory]
from   AddressBook   where   [owner]=@owner   and   [addressCategory]   in   ( '+@addressCategory+ ') '
exec(@sql)
return  
GO


Msg   137,   Level   15,   State   2,   Line   17
必须声明标量变量   "@owner "。


[解决办法]
from AddressBook where [owner]=@owner and [addressCategory] in ( '+@addressCategory+ ') '

-->


from AddressBook where [owner]= ' + cast(@owner as varchar(100)) + ' and [addressCategory] in ( '+@addressCategory+ ') '

热点排行