Group:  Microsoft Access ยป microsoft.public.access.adp.sqlserver
Thread: Parameterized SP in WHERE Clause of Another SP

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Parameterized SP in WHERE Clause of Another SP
"jeremyNYC" <jeremygetsmail[ at ]gmail.com> 06.06.2006 08:57:01
I've got this SP:
CREATE PROCEDURE
EWF_spCustom_AddProfiles_CompanyYear
[ at ]prmSchoolYear char(11)
AS
SELECT
ContactID
FROM
dbo.EWF_tblCustom_CompanyProfile
WHERE
SchoolYear = [ at ]prmSchoolYear

I'd like to be able to reference that in the where clause of another
SP. Is that possible?

I'd like to end up with something like this:
CREATE PROCEDURE
MyNewProc
[ at ]prmSchoolYear2 char(11)
AS
SELECT
ContactID, SomeOtherFields
FROM
tblContact
WHERE
ContactID IN (exec EWF_spCustom_AddProfiles_CompanyYear
[ at ]prmSchoolYear2)

How would I make that happen?

If this isn't possible, what else might I try?

Thanks much for any pointers.

Jeremy

Re: Parameterized SP in WHERE Clause of Another SP
"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)> 06.06.2006 14:10:25
You should ask this type of question in m.p.sqlserver.programming.

The usual way of doing this is to create a self-referenced linked server and
use an OPENQUERY. You can also use an OPENROWSET. Another possibility
would be to use a temporary table (or a local variable table) to transmit
data between these two procedures. You can also EXEC your statement to
append your data directly into

However, in your case, you should strongly consider the possibility of using
a function instead of a stored procedure. (Unless if you are on a SQL-Server
7 or less, of course).

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF


"jeremyNYC" <jeremygetsmail[ at ]gmail.com> wrote in message
news:1149584221.876336.204830[ at ]i40g2000cwc.googlegroups.com...
[Quoted Text]
> I've got this SP:
> CREATE PROCEDURE
> EWF_spCustom_AddProfiles_CompanyYear
> [ at ]prmSchoolYear char(11)
> AS
> SELECT
> ContactID
> FROM
> dbo.EWF_tblCustom_CompanyProfile
> WHERE
> SchoolYear = [ at ]prmSchoolYear
>
> I'd like to be able to reference that in the where clause of another
> SP. Is that possible?
>
> I'd like to end up with something like this:
> CREATE PROCEDURE
> MyNewProc
> [ at ]prmSchoolYear2 char(11)
> AS
> SELECT
> ContactID, SomeOtherFields
> FROM
> tblContact
> WHERE
> ContactID IN (exec EWF_spCustom_AddProfiles_CompanyYear
> [ at ]prmSchoolYear2)
>
> How would I make that happen?
>
> If this isn't possible, what else might I try?
>
> Thanks much for any pointers.
>
> Jeremy
>


Re: Parameterized SP in WHERE Clause of Another SP
"Vadim Rapp" <vrapp[ at ]nospam.polyscience.com> 06.06.2006 20:46:36
Hello jeremyNYC:

j> I'd like to be able to reference <stored procedure> in the where clause
of another
j> SP. Is that possible?

No.

j> How would I make that happen?

copy and paste the select from the 1st sp inside the parenthesis in the 2nd
one, and adjust parameter name.


Vadim Rapp

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net