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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-01-09 : 08:25:57
|
| Alin writes "Hello.I have a question for you.I am using sql server 7. I have a stored procedure called top_client with 3 parameters (firm,datai,dataf). I want to execute this procedure using sp_executesql and I dont know how.I would apreciate any help. thank you." |
|
|
Pumkin
Starting Member
20 Posts |
Posted - 2006-01-09 : 09:03:19
|
| DECLARE @sql nvarchar(100)SET @sql=N'EXEC dbo.top_client '''firm''','''datai''','''dataf''''EXEC dbo.sp_executesql @sql |
 |
|
|
Pumkin
Starting Member
20 Posts |
Posted - 2006-01-09 : 09:10:13
|
| I'm really sorry for that. A little corection. I seem to put too many quotes. :PDECLARE @sql nvarchar(100)SET @sql=N'EXEC dbo.top_client ''firm'',''datai'',''dataf'''EXEC dbo.sp_executesql @sqlThat will work fine. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2006-01-09 : 10:06:08
|
| Sorry for stating the obvious but I just want to make sure you know:To execute a stored procedure in sql server, you don't have to use "sp_executesql". From a Query Analyzer window you can simply:exec <spname> [parameter=value parameter list]Be One with the OptimizerTG |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-09 : 11:32:54
|
| Can't this be done without exec part ?I mean usingSPName para1, para2 --> execute in QA ? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2006-01-09 : 12:45:45
|
| Yes, but only if the statement is run as a single statement, and not as a block of statements.I always put the EXEC in so I don't forget when its a Block rather than a Singleton!!Kristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-10 : 01:24:29
|
quote: Originally posted by Srinika Can't this be done without exec part ?I mean usingSPName para1, para2 --> execute in QA ?
YesBut if you need to execute more than one sp then you need to use Go to seperate themMadhivananFailing to plan is Planning to fail |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-10 : 10:02:58
|
Thanks Kristen & Madivanan |
 |
|
|
|
|
|