December 10, 2008 at 1:12 pm
The EXECUTE sp_executesql allows the dynamic execution of a SQL statement where that statement is limited to a variable of NVARCHAR(4000). It appears that I can use an NTEXT value, but I cannot see any way to create a temporary NTEXT value in a script.
Any ways to get past the NVARCHAR(4000) limit in a SQL script?
December 10, 2008 at 1:37 pm
It may be declared as a parameter of SP.
_____________
Code for TallyGenerator
December 10, 2008 at 1:53 pm
I don't know how big the script you need is, but you can concatenate multiple nvarchar's together during the EXEC call.
declare @nv1 nvarchar(4000)
declare @nv2 nvarchar(4000)
select @nv1=replicate('select getdate();',235);
select @nv2=replicate('Print ''Hello There''',210);
select len(@nv2);
Exec (@nv1+@nv2)
Just in case you were in 2005 - you could just simply switch to nvarchar(max), too.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
December 10, 2008 at 1:55 pm
are you trying to exceed the nvarchar(4000) to use in an sp_executesql statement?
I don't know that you can.
what in the world are you trying to execute that is that long?
Just for designating an nvarchar string > 4000 , you can use nvarchar(max) and declare that within your script.
Still I don't think you can execute it if is > 4000
December 10, 2008 at 2:03 pm
Ray M (12/10/2008)
are you trying to exceed the nvarchar(4000) to use in an sp_executesql statement?I don't know that you can.
what in the world are you trying to execute that is that long?
Just for designating an nvarchar string > 4000 , you can use nvarchar(max) and declare that within your script.
Still I don't think you can execute it if is > 4000
2005 will execute something >4000 in a nvarchar(max). I've done it before (if nothing else - just to prove to myself it could be done).
SQL Server 2000 will do the concat trick above as well....
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply