Hi,
This is regarding the sp_executesql and the sql statement parameter, in processing a dynamic SQL on SQL Server 2000, in my stored procedure.
I have my SQL string exeeding more than 4000 characters.
The sp_executesql expects its parameters to be declared as nvarchar/ntext.
ntext cannot be declared for a local variable and nvarchar has a maximum limit of 4000 characters.
The following was the original approach.
===============
DECLARE @sql nvarchar(4000),
---
--
select @sql=@sql+'sele ct............. ....'
--
--
INSERT INTO #Temp
EXEC sp_executesql @SQL,@paramlist
=============== =============== =
The above sql was split into two sql variables and tried in the following way.
=============== ===============
DECLARE @sql nvarchar(4000), @sql1 nvarchar(4000), @paramlist nvarchar(4000)
---
--
select @sql=@sql+'sele ct............. ....'
select @sql1=@sql1+'fr om table1, table2......... '
--
--
INSERT INTO #Temp
exec('EXEC sp_executesql ''' + @sql + @sql1 + ''',@paramlist' )
=============== =====
However, it compiles correctly but during the execution, the error indicates as syntax error.
I ran the resulting SQL string (@sql + @sql1) separately, and it runs fine without any syntax errors returning rows, but when execute through
sp_executesql, it gives me error
Appreciate if anyone can suggest a workaround for this situation.
1 8263 iburyak 1,017
Recognized Expert Top Contributor
sp_executesql does not accept concatenated strings.
I have one server that has limitation 4000 characters
Microsoft SQL Server 2000 - 8.00.760 (Intel X86)
and another server which has 8000 characters
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
To see what you have execute sp_server_info
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: cliverama |
last post by:
help! fried brains....
asp calling a sqlserver7 stored proc which dynamically builds a
sqlstatement & passes it to sp_executesql
asp page gives the operation not allowed when object is closed error
this is the asp code:
Set connInc= server.CreateObject("ADODB.Connection")
connInc.Open "DSN=db_database;User ID=userid;Password=xxxxxx"
Set rsInc= server.CreateObject("ADODB.Recordset")
|
by: Justin Wong |
last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords
(
@item varchar(50),
@last datetime
)
AS
SET NOCOUNT ON
|
by: DBA |
last post by:
Does anyone know the technical reason for why sp_executesql uses the N
prefix before the string that is passed?
For example:
sp_executesql N'USE Northwind'
Thanks!
|
by: Clausmeyer |
last post by:
I want to execute a dynamically generated sql-statement
from inside an user-defined-function. Calling functions and
extended stored-procs is allowed so I tried sp_executesql
as well as sp_prepare/sp_execute ....
but both fail with an error 'only functions and extended stored-procs
may be called from inside a function.'
any idea where I might be wrong ?
|
by: LineVoltageHalogen |
last post by:
Greetings All, I have a very large query that uses dynamic sql. The
sql is very large and it requires it to be broken into three components
to avoid the nvarchar(4000) issue:
SET @v_SqlString(
N'')
SET @v_SqlString2(
N'')
| |
by: Highlander416 |
last post by:
This is driving me crazy.
I need to create a UDF that would return a TRUE/FALSE (bit) value based
on a comparison it does.
CREATE FUNCTION dbo.SelectedByApplication
(
@ApplicationID int,
@TableToCheck nvarchar(50),
@ColumnToCompare nvarchar(50),
|
by: Matik |
last post by:
Hi to all,
Probably I'm just doing something stupid, but I would like you to tell
me that (if it is so), and point the solution.
There ist the thing:
I' having a sp, where I call other sp inside.
The only problem is, the name of this inside sp is builded variously,
and executed over sp_executesql:
|
by: fireball |
last post by:
please, in simple words, what is difference between :
sp_executesql
and
EXECUTE
in sql2005
?
|
by: Yash |
last post by:
Hi,
I am using SQL 2000 SP4.
I have compared 2 scenarios:
Scenario 1:
insert into #bacs_report
SELECT .....
WHERE <conditions>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |