473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

syntax of sp_prepexec, sp_execute

The following was captured from SQL Profiler during an interaction between
Access Xp and SQL Server 2000:

declare @P1 int
set @P1=1
exec sp_prepexec @P1 output, N'@P1 nvarchar(50)', N'SELECT
"totalid","FPSID","IFPSSYSID","FAMLNAME","OTHAGENI D",
"FromFPW","prevdown","tempifpssysid","upsize_t s"
FROM "dbo"."Family"
WHERE "totalid" = @P1', N'-:1044463096'
select @P1
go

I think I understand that sp_prepexec prepares a parameterized query with
@P1 as a variable...but sp_prepexec is not in Books Online...

could someone please explain the syntax of sp_prepexec?

why is @P1 used for both the parameter within the select query and the name
of the prepared statement?

the other seemingly strange thing, is that when I run the above in Query
Analyzer and try to use the parameterized query like so

exec sp_execute 1, N'-:1044463096'
go

I receive the error message

Could not find prepared statement with handle 1
Jul 20 '05 #1
1 17764
> > declare @P1 int
set @P1=1
exec sp_prepexec @P1 output, N'@P1 nvarchar(50)', N'SELECT
"totalid","FPSID","IFPSSYSID","FAMLNAME","OTHAGENI D",
"FromFPW","prevdown","tempifpssysid","upsize_t s"
FROM "dbo"."Family"
WHERE "totalid" = @P1', N'-:1044463096'
select @P1
go I receive the error message

Could not find prepared statement with handle 1
Did you run sp_prepexec in the same session? I would guess that the handle
is session-specific. I was able to get this to work:

declare @x int
exec sp_prepexec @x OUTPUT, N'@pid nchar(5)',
N'SELECT * FROM Customers WHERE CustomerID = @pid', @pid = N'ALFKI'
select @x
exec sp_execute @x, N'BERGS'


I'm looking at something similiar, but I'm a newbie to SQL. Anyway I wanted
to capture messages to the database from an application and replay them
later. I got the same message.
It seem you can get it to work as long as you remove the lines with:

set @P1=1

in them. I did this with a chunky bit of sql and it seemed happy.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Ken in Melbourne Australia | last post by:
If I use the curly bracket syntax (referred to as the complex syntax) within a string, how do I get to call a function within it? The php manual says that the first (or previous) character for...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
22
by: Tuang | last post by:
I'm checking out Python as a candidate for replacing Perl as my "Swiss Army knife" tool. The longer I can remember the syntax for performing a task, the more likely I am to use it on the spot if...
14
by: Sandy Norton | last post by:
If we are going to be stuck with @decorators for 2.4, then how about using blocks and indentation to elminate repetition and increase readability: Example 1 --------- class Klass: def...
1
by: Peter Scheurer | last post by:
I have a statement that works in compatibility mode 8 of SQL Server 2000 while it fails in 7: declare @P3 int exec sp_prepexec @P3 output, N'@P1 float', N'select custname from customer where...
19
by: Nicolas Fleury | last post by:
Hi everyone, I would to know what do you think of this PEP. Any comment welcomed (even about English mistakes). PEP: XXX Title: Specialization Syntax Version: $Revision: 1.10 $...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: codefragment | last post by:
Hi I'm sure lots of people have asked this before, but I can't find any threads so: Assuming you haven't had your profiler open for long enough is there any way of getting to the procedure...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.