Solved

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

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

617 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