Stored Procedure

  • I could really use some help with this!

    I need to Create a stored procedure named spBalanceRange that accepts three optional parameters. The procedure returns a result set consisting of VendorName, InvoiceNumber, and Balance for each invoice with a balance due, sorted with largest balance due first. The parameter @VendorVar is a mask that's used with a LIKE operator to filter by vendor name. @BalanceMin and @BalanceMax are parameters used to specify the requested range of balances due. If called with no parameters, the procedure should return all invoices with a balance due.

    I am using SQL server 2008, here is what I have so far. Not sure how I am suppose to add the select statement to add my three columns.

    Create Proc spBalanceRange

    @VendorVar VarChar(40) = '%',

    @BalanceMin money = null,

    @BalanceMax money = null

    AS

    IF @BalanceMin IS Null

    Select @BalanceMin = Min(InvoiceTotal )

    From Invoices

    Select @BalanceMax = Max(InvoiceTotal )

    From Invoices Join Vendors

    On Invoices.VendorID = Vendors.VendorID

    Where (InvoiceTotal >= @BalanceMin) AND

    (Vendorname Like @VendorVar)

  • seems that if you google

    "Create a stored procedure named spBalanceRange that accepts three optional parameters."

    you may find what you are looking for.....

    if not or confused pls post back

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • New year, same homework assignments?

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply