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 2008 Forums
 Transact-SQL (2008)
 Pass text data type result to sp_executesql

Author  Topic 

kensai
Posting Yak Master

172 Posts

Posted - 2011-01-28 : 08:27:52
I have a table which has a ntext type column. In that column I have some sql code that I want to run. I want to query this table, get this columns value and pass it to sp_executesql. How can I do this? I can't select it into a variable because you can't create ntext type variables. I can't use exec and varchar because the query is longer then 8000 characters. Any ideas?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-01-28 : 08:33:36
You can create a nvarchar(max) variable - but doesn't help because xp_cmdshell is limited to nvarchar(4000)
Write it to a file and use sqlcmd?

Sorry - misread. You're using sp_executesql which will take a nvarchar(max).



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -