If you call your procedure like this
Exec sp_getClientTransactioninfo '2001-01-01'
Then you are going to get an error saying that the procedure expects the missing parameter @ToDate
. The missing parameter is not set as null, it is just not there so SQL server throws an error saying it was expecting the parameter before even executing your procedure.
You can get around this, by setting your parameters to null in the declaration of your procedure, like so:
Alter PROCEDURE sp_getClientTransactioninfo
@FromDate DATETIME = null,
@ToDate DATETIME = null,
@Active int
So if you do not provide the parameter, it will default to null and then your error message with show.
You may also want to look into RAISEERROR
rather then PRINT