当前位置: 代码迷 >> Sql Server >> 存储过程int参数有关问题
  详细解决方案

存储过程int参数有关问题

热度:37   发布时间:2016-04-27 20:53:26.0
存储过程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][email protected]   and   [addressCategory]   in   ( '[email protected]+ ') '
exec(@sql)
return  
GO


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


------解决方案--------------------
from AddressBook where [owner][email protected] and [addressCategory] in ( '[email protected]+ ') '

-->


from AddressBook where [owner]= ' + cast(@owner as varchar(100)) + ' and [addressCategory] in ( '[email protected]+ ') '
  相关解决方案