Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

code for calling a stored procedure called spDateRange Expand / Collapse
Author
Message
Posted Sunday, August 05, 2012 6:46 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Sunday, November 25, 2012 5:50 PM
Points: 40, Visits: 66
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);
Post #1340320
Posted Sunday, August 05, 2012 10:28 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, April 09, 2014 9:03 PM
Points: 1,128, Visits: 1,161
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
Post #1340335
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse