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)
 sp_executesql limitation

Author  Topic 

ofsouto
Starting Member

22 Posts

Posted - 2005-02-01 : 05:53:47
Hi, dear

I need to execute a dynamic sql query but it has more than 4000 characteres.
There are parameters on query.
I tried to divide the query to 2 nvarchar(4000) variables but
I got error when I tried to execute the commands bellow:
EXEC ('EXEC sp_executesql N''' + @sql1 + @sql2 + '''')
EXEC('EXEC sp_executesql N' + @sql1 + @sql2)
I think the problem is the use of parameters on query.
How can I solve this problem?

Thank you very much.

Obede
Brazil

Andraax
Aged Yak Warrior

790 Posts

Posted - 2005-02-01 : 06:01:20
Try using an ntext variable to hold your finished command, and run that with the sp_exeutesql proc.
Go to Top of Page

ofsouto
Starting Member

22 Posts

Posted - 2005-02-01 : 06:06:00
I think I can't use ntext variable. Is it possible? How can I use it?
Go to Top of Page

ofsouto
Starting Member

22 Posts

Posted - 2005-02-01 : 06:24:11
I have the problem solved.

I created a VARCHAR(8000) variable.

Then I create the query as bellow:
SET @sql = 'N''''SELECT ...

I execute the command bellow:
EXEC('EXEC sp_executesql ' + @sql)

Thank you very much

Obede
Brazil
Go to Top of Page
   

- Advertisement -