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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 My dynamic query is not working

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-09-20 : 10:14:04
Norman writes "I have a stored procedure that I am passing a view name to to determine which of 3 views to use. I am recieving an error
"Cannot convert parameter '@statement' to ntext/nchar/nvarchar data type expected by procedure." when I try to run it. I am new to stored procedures and T-SQL so please be gentle. Our DBA
creatd the procedure and I am just trying to use it.

Thanks for the Help

Norman Rekitt
nrekitt@zefer.com

-------Snippet----------------------------------
CREATE PROCEDURE usp_PagedRecipes
(
@Page int,
@RecsPerPage int,
@TableName varchar(30)
)
AS
### The error seem to occur around here ###
DECLARE @v_SQLString varchar(200)

SET @v_SQLString = N'INSERT INTO #TempItems (recipe_id, recipe_name, short_desc, recipe_image, category,sub_category)
SELECT recipe_id, recipe_name, short_desc, recipe_image, category,sub_category FROM ' + @TableName

/* Execute the string with the first parameter value. The string will insert the rows from the parameterized table
into the temp table */

EXECUTE sp_executesql @v_SQLString"
   

- Advertisement -