Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query

Status
Not open for further replies.

Carney123

Programmer
Apr 11, 2008
15
US
I have following table
Type Description Amount
I Cash 100
I Cash 200
I Cash 300
I Express 1000
I Express 1000
M Money 200
M Money 200
N Net 10000
N Net 500
L Loan 200
L Loan 200

I need to write a procedure to pass type as a parameter,
if I pass M as a parameter. I should get 'I' records include with M records. Not 'N' and 'L' Records.
Similarly If I pass 'N', I should get 'I' records include with 'N' records and should exclude 'M' and 'L' Records.

Any help will be appreciated.
 
You should ALWAYS get 'I' records, right? No matter what parameter you passed, if this is so:
Code:
CREATE PROCEDURE MyTestSP
       @MyType char(1)
AS
BEGIN
     IF @MyType IS NULL
        RETURN -1
     
      SELECT * FROM YourTable
          WHERE [Type] IN ('I', @MyType)
END


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top