Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-04-29
3
Medium Priority
?
443 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
  • 2
3 Comments
 
LVL 70

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 70

Accepted Solution

by:
Scott Pletcher earned 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

972 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