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
 SQL Server Development (2000)
 Passing Parameters through one SP into another..

Author  Topic 

Glendale
Starting Member

5 Posts

Posted - 2008-01-25 : 10:36:54
Hi all. I'm running SQL Server 2000 with an Access 2003 frontend. I have a query, lets call it Master, which calls 6 other queries. Currently, all queries are stored and run on the Access side, but running the master query takes about 2 minutes, so I need to move them all to the server..

My problem is that 2 of the child queries require parameters...

So we've got:


Master
(calls)
---Child 01
---Child 02
---Child 03 <--Takes a date parameter from a form
---Child 04 <--Takes a date parameter from a form
---Child 05
---Child 06


This works fine the way it's set up now. Since it's all running through Access, the stored procedure just looks to the form to pull the required parameters..

Now I've done this in the past. I know how to take an Access stored procedure, move it to SQL Server and pass a parameter through the old Access Query into the new SPROC on SQL Server.. What I don't know is how to pass a parameter from Access through the Master query into the Children.. I just can't seem to picture the syntax and my google-fu is failing me this morning..

I hope I'm explaining this well. It's been a long week and I still haven't had my first cup of coffee... I can post the queries if necessary..

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-25 : 10:45:13
Add a new param in master and pass the value to be send to children and use this parameter where you invoke the children.
Go to Top of Page

Glendale
Starting Member

5 Posts

Posted - 2008-01-25 : 11:08:56
But what's the syntax for passing the parameter to the children?


SELECT
Child1.Year,
Child2.Year,
Child3.Year,
Child4.Year,
etc...
FROM
Child1,
Child2,
etc...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-25 : 11:29:50
If parameter used in SP is @Param then use @param just like you use a variable in queries

ex:SELECT fields FROM TABLE where field=@Param
Go to Top of Page
   

- Advertisement -