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)
 Execute stored proc question!

Author  Topic 

sqlserverdeveloper
Posting Yak Master

243 Posts

Posted - 2008-08-14 : 17:02:42
I have a simple question, I am trying to execute a storedproc the following way which has about 5 input parameters.
SQL:
Execute storedproc
Select col1,col2,col3,col4,col5 from #Temp

I am passing in col1,col2,col3,col4,col5 as parameters. I am getting the follow error:
Msg 201, Level 16, State 4, Procedure storedproc, Line 0
Procedure 'storedproc' expects parameter '@param1', which was not supplied.

Thanks for your responses!!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-14 : 17:10:12
You can't run a SELECT statement and pass that to a stored procedure, like that at least. Could you explain what you are trying to do?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-14 : 17:12:41
[code]DECLARE @Col1 INT,
@Col2 INT,
@Col3 INT,
@Col4 INT,
@Col5 INT

SELECT @Col1 = Col1,
@Col2 = Col2,
@Col3 = Col3,
@Col4 = Col4,
@Col5 = Col5
FROM #Temp

EXEC StoredProc @Col1, @Col2, @Col3, @Col4, @Col5[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sqlserverdeveloper
Posting Yak Master

243 Posts

Posted - 2008-08-14 : 17:29:52
quote:
Originally posted by Peso

DECLARE	@Col1 INT,
@Col2 INT,
@Col3 INT,
@Col4 INT,
@Col5 INT

SELECT @Col1 = Col1,
@Col2 = Col2,
@Col3 = Col3,
@Col4 = Col4,
@Col5 = Col5
FROM #Temp

EXEC StoredProc @Col1, @Col2, @Col3, @Col4, @Col5



E 12°55'05.25"
N 56°04'39.16"




Thanks! it worked.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-08-14 : 17:34:05
Remember if you have several records in #Temp table and want to execute StoredProc for all of them, record by record, you have to implement a loop mechanism.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -