Link to home
Start Free TrialLog in
Avatar of timberadmin
timberadminFlag for Canada

asked on

SQL variable restriction

I'm creating a stored proc with a variable @AsOfDate as date. Now, I only want to accept the input date if it is within 3 days of today, otherwise it should not accept it and throw an error. Currently I'm doing this with a IF/ELSE statement. Is there a better way of handling this?

I'm using SQL 2012
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of timberadmin

ASKER

So that's exactly how I'm doing it right now. I assume this is the correct and most efficient way of handling it?
I'm sure there are other ways, but this is the way I'd do it.

btw Did you really want to throw an error, which would involve RAISEERROR, or just handle it?
If this stored proc is run from Excel VBA, I want the user to see the error message I give.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial