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
 Transact-SQL (2000)
 How to Execute Query Saved in a Text Column

Author  Topic 

bridge
Yak Posting Veteran

93 Posts

Posted - 2006-02-01 : 08:08:01
If the query length is more than 8000 characters and it is saved in a table column having text data type then how can execute this query using TSQL?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-01 : 08:53:03
select substring(textCol,8001,8000) from yourTable

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Norwich
Posting Yak Master

158 Posts

Posted - 2006-02-02 : 12:21:58
I'm Assuming that the Query is the only thing that's saved in the column

Declare @SQl Text

Select @SQL = ColumnName
from YourTable

Execute (@SQL)


N

The revolution won't be televised!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-03 : 09:15:57
quote:
Originally posted by Norwich

I'm Assuming that the Query is the only thing that's saved in the column

Declare @SQl Text

Select @SQL = ColumnName
from YourTable

Execute (@SQL)


N

The revolution won't be televised!


You will get the error

Server: Msg 2739, Level 16, State 1, Procedure #t, Line 3
The text, ntext, and image data types are invalid for local variables.

To deal with more than 8000 characters, search for 8000 in this topic
http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -