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)
 help with dynamic sql

Author  Topic 

leoguy
Starting Member

1 Post

Posted - 2006-07-12 : 19:10:15
I have to run a dynamic sql that i save in the database as a TEXT data type(due to a large size of the sql.) from a .NET app. Now i have to run this sql from the stored proc that returns the results back to .net app. I am running this dynamic sql with sp_executesql like this..

EXEC sp_executesql @Statement,N'@param1 varchar(3),@param2 varchar(1)',@param1,@param2,
GO

As i can't declare text,ntext etc variables in T-Sql(stored proc), so i am using this method in pulling the text type field "Statement".

DECLARE @Statement varbinary(16)
SELECT @Statement = TEXTPTR(Statement)
FROM table1
READTEXT table1.statement @Statement 0 16566

So far so good, the issue is how to convert @Statment varbinary to nText to get it passed in sp_executesql.

Also i don't want to run the @Statement(saved in database text col) from .NET applcations because then i have to make changes at many places in the app.

I would appreciate if any body respond to this.

   

- Advertisement -