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)
 User-Defined Parameters in a Stored Procedure...

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-06-11 : 08:19:22
Brenda writes "Here's what I'm trying to do...
I have a stored procedure that consists of a union join and a user-defined parameter telling SQL which of the two choices to use. Below is a very skeleton version of the proc...

CREATE Procedure testLineDetail1
@selectby varchar (10)
As
If @selectby = 'Borrower'
Begin
SELECT TclTable = 'PROP', ...
FROM ...
WHERE ...and pbnumber in ('0011','0196','0249','0321')

UNION

SELECT TclTable = 'PIP', ...
FROM ...
WHERE ...and pbnumber in ('0011','0196','0249','0321')
End

If @SelectBy = 'Officer'
Begin
SELECT TclTable = 'PROP', ...
FROM ...
WHERE ...and bofficer = '017'

UNION

SELECT TclTable = 'PIP', ...
FROM ...
WHERE ...and bofficer = '017'
End


I need for the user to be able to choose, not only between "Borrower" & "Officer"...But THEN, they need to choose the "pbnumber" or "bofficer"(Which could be more than one in either case)...What could you tell me is the best approach to this? And am I even making sense with this question? Any Help is greatly appreciated.
Thank You in advance,
Brenda"
   

- Advertisement -