Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mcotter
Starting Member
3 Posts |
Posted - 2008-02-03 : 16:22:22
|
I created a SQL procedure that uses an input parameter. This procedure also uses sp_executesql. ----------------------------------------Create PROCEDURE [dbo].[PersonAddress] ( @AddressID int)ASdeclare @sql nvarchar(MAX)/*select * from Person.Address where AddressID = @AddressID */set @sql = N'select * from Person.Address where AddressID = @AddressID'exec sp_executesql @sql, N'@AddressID int'--------------------------------------------------When I use just the select statement, the procedure works. When I use sp_executesql,I get the following error:The parameterized query '(@AddressID int)select * from Person.Address where AddressID = @' expects the parameter '@AddressID', which was not supplied.Can anyone identify the issue? |
|
mcotter
Starting Member
3 Posts |
Posted - 2008-02-04 : 10:02:02
|
I found the problem. The following command should be--exec sp_executesql @sql, N'@AddressID int', @AddressID |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
|
|