1markmc
asked on
Need to execute A Large (>4000 char) unicode statement using sp_executesql
I have a large statement @SQL that can dynamically grow up to about 6000 characters.
I need to execute this statement using :
sp_executesql
since the stored procedure parameter accepts only a single variable and the + operator is not allowed, how can I execute this statement using this stored procedure?
I need to execute this statement using :
sp_executesql
since the stored procedure parameter accepts only a single variable and the + operator is not allowed, how can I execute this statement using this stored procedure?
AFAIK, you will have to use a type of NTEXT. You could create the query in two 4000-char NVARCHAR variables then concatenate that into an NTEXT field. Sorry, don't know any other way.
ASKER
So how would I insert the ntext value (which as I understand it exists only as a table field) into the sp_executesql statement.
I worked up the following to test some ideas but haven't found any that work
declare @a nchar(3)
declare @b nchar(3)
set @a = N'sp_'
set @b = N'who'
declare @table table (sql ntext NULL)
insert into @table values (@a + @b)
--this doesn't work and so is where I need help
exec sp_executesql (select top 1 sql from @table)
I worked up the following to test some ideas but haven't found any that work
declare @a nchar(3)
declare @b nchar(3)
set @a = N'sp_'
set @b = N'who'
declare @table table (sql ntext NULL)
insert into @table values (@a + @b)
--this doesn't work and so is where I need help
exec sp_executesql (select top 1 sql from @table)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.