Solved

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

Posted on 2004-04-29
3
433 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 69

Expert Comment

by:ScottPletcher
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:
ScottPletcher 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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.
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.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now