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.
| Author |
Topic |
|
ofsouto
Starting Member
22 Posts |
Posted - 2005-02-01 : 05:53:47
|
| Hi, dearI 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 butI 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.ObedeBrazil |
|
|
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. |
 |
|
|
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? |
 |
|
|
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 muchObedeBrazil |
 |
|
|
|
|
|