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]+ ') '