Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 using sp_executesql

Author  Topic 

MuadDBA

628 Posts

Posted - 2005-11-22 : 15:12:23
I am trying to code, for the first time, an sp_executesql statement that calls a stored procedure.

Any help as to what I might be doing wrong would be appreciated. Here is what I am entering:

sp_executesql N'exec sp_add_folder1(@P1,@P2)', N'@P1 varchar(7),@P2 varchar(3)', 'P000002', 'JOE'

what am I doing wrong? I get a syntax error near @P1 message when I try to execute it, but I can't seem to see what I am doing wrong.

Help?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2005-11-22 : 15:16:12
Why are you trying to do this dynamically?

DECLARE @P1 varchar(7), @varchar(3)
SELECT @P1 = 'P000002', @P2 = 'JOE'
EXEC sp_add_folder1 @P1, @P2

or

EXEC sp_add_folder1 'P000002', 'JOE'

Tara Kizer
aka tduggan
Go to Top of Page

MuadDBA

628 Posts

Posted - 2005-11-22 : 19:32:16
It's an unfortunate lmitation of the front-end ap i am dealing with. It has a way for us to (pardon me) execute SQL from inside the app, but it's rather kludgy and this is the result.

Can someone please tell me what part of the syntax is wrong, so perhaps I can try to rethink how I am executing stuff from the app.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-23 : 01:08:58
Post the code used in sp_add_folder1 procedure

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-11-23 : 01:51:53
As Tara suggested
quote:
EXEC sp_add_folder1 'P000002', 'JOE'


or if you insist on using sp_executesql
sp_executesql N'exec sp_add_folder1 ''P000002'', ''JOE'''

but this is a bit ridiculous

-----------------
[KH]
Go to Top of Page
   

- Advertisement -