I've gotten the method to work using the execute(@sql) method, but I want to use sp_executesql which should perform better as the database grows since SQL doesn't need to recompile the statement every time.
here's the test shell.... I will eventually have 15 parameters coming in from the web page
CREATE PROCEDURE test_sql
@base_id char(3)
AS
declare @sqlstring nvarchar(1000)
declare @wherestring nvarchar(500)
declare @paramstring nvarchar(500)
set @sqlstring = N'Select * from tbl_buildinginfo where base_id = @base_id1'
set @wherestring =N' where base_id = @base_id1'
set @paramstring = N'@base_id1 char(3)'
set @sqlstring = @sqlstring + @wherestring
print @sqlstring
execute sp_executesql @sqlstring,@paramstring,@base_id1 = @base_id
RETURN
I run the stored proc and the print statement shows me this
Select * from tbl_buildinginfo where base_id = @base_id1
so the sp_executesql method is not seeing the parameter passed to it through the web page.
Any help would be greatly appreciated