code for calling a stored procedure called spDateRange

  • Code a call to the stored procedure That returns Invoices with an InvoiceDate Between April 10 and april 20 2008 This call should also catch any errors that are raised by the procedure and print the error number and description

    I am using sql server 2008 and here is my code for the stored procedure (not sure if it is all correct);

    Create Proc spDateRange

    @DateMin VarChar(30) = Null,

    @DateMax VarChar(30) = Null

    AS

    Select InvoiceNumber, InvoiceDate, Invoicetotal, invoiceTotal - PaymentTotal AS Balance

    From Invoices

    PRINT @DateMin;

    PRINT @DateMax;

    IF @DateMin IS NOT NULL AND @DateMax IS NOT NULL

    BEGIN

    PRINT @DateMin;

    IF(ISDATE(@DateMin)=1 AND ISDATE(@DateMax)=1)

    PRINT 'Valid Date';

    ELSE

    RAISERROR('Parameters not date format', 10, 1);

    END

    ELSE

    RAISERROR ('Invalid parameters', 10, 1);

  • Create an SP that takes the validation error input and prints the message;

    that would make it cleaner.

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

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

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