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 |
|
danyeung
Posting Yak Master
102 Posts |
Posted - 2008-08-06 : 10:43:59
|
| I want to exec a dynamic sql by using exec sp_ExecuteSQL @strSQL in a stored procedure, but the problem is the variable can hold only 4000 charecters max and my sql statement is over the max. How can I concatenate multiple sql strings and get the result? Thanks.DanYeung |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-06 : 10:47:36
|
use nvarchar(max) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-06 : 10:51:56
|
| NVARCHAR(MAX) is 2005 and up only (which is fine because you've posted in a 2005 forum)....recommended reading for all your dynamic sql needs :: http://www.sommarskog.se/dynamic_sql.html-------------Charlie |
 |
|
|
danyeung
Posting Yak Master
102 Posts |
Posted - 2008-08-06 : 11:18:59
|
| How many characters are in nvarchar(max)? Thanks.DanYeung |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-08-06 : 11:23:52
|
| max indicates that the maximum storage size is 2^31-1 bytes.Each NVARCHAR character is 2 bytes wide so :: 2^30-1= 1073741823 characters.Check out the link I posted. It's a seriously good resource-------------Charlie |
 |
|
|
danyeung
Posting Yak Master
102 Posts |
Posted - 2008-08-07 : 11:16:34
|
| nvarchar(max) works. Thanks.DanYeung |
 |
|
|
|
|
|