|
|
|
SSC 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);
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 4:10 AM
Points: 1,092,
Visits: 1,122
|
|
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
|
|
|
|