Solved

Need to execute A Large (>4000 char) unicode statement using sp_executesql

Posted on 2004-04-29
3
440 Views
Last Modified: 2008-01-09
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?
0
Comment
Question by:1markmc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 10952388
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.
0
 
LVL 1

Author Comment

by:1markmc
ID: 10952773
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)
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 total points
ID: 10952827
I think it can be an input parameter to a SP, but can then be manipulated as desired once inside the SP.  Sorry, I meant to mention that earlier.  If this is this being done within a SP, hopefully that will help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question