June 1, 2017 at 9:40 am
I have a stored procedure with a parameter. I would like to force the input to be at least five characters. Is there a way to accomplish this in my query? Is this something that must be defined in the variable of the query?
June 1, 2017 at 9:51 am
As always, it depends on the implementation.
if it is just an SSMS consumption,
at the procedure level, all you can do is add an error;IF LEN(@param) < 5
BEGIN
RAISERROR('Parameter must be at least five characters',16,1)
return;
END
if the procedure is consumed by an application, or an SSRS report, etc, the app should validate the parameter prior to the call to the procedure,and be designed to handle any errors that might be returned.
Lowell
June 1, 2017 at 9:56 am
My next step will be to deploy this as a dataset in SSRS. If I create the "constraint" and error in my SPROC, will SSRS recognize the error?
Is there a way to implement a min character length in SSRS, or should I post that question to the RS forum?
June 1, 2017 at 10:26 am
yes, SSRS can use an expression to validate the length of your input;
this stackoverflow has an example that was testing a credit card length = 16, basically the same thing you are after.
https://stackoverflow.com/questions/18189836/ssrs-validate-user-input-length
Lowell
June 1, 2017 at 10:31 am
Thanks! I swear I googled this several times looking for an answer. I guess my combination of words was off.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply