'Allow stored procedure to accept the values
I new to SQL, and I need one parameter called @User1 in the stored procedure to accept just 3 words for example ('max', 'low', 'high'), otherwise it should be an error.
I try to type this but it doesn't work I mean it accept any string value of data and I need to just 3 words:
IF @User1 <> 'max' OR @User1 <> 'low' OR @User1 <> 'high'
BEGIN
SET @ErrorNumber = 3
RETURN 0
END
Solution 1:[1]
I think you are trying to create a stored procedure that accepts one parameter and you want to check that the parameter is in [max, low, high].
Check this
CREATE PROCEDURE UserSize @User1 nvarchar(30)
AS
BEGIN
IF @User1<>'max' or @User1<>'low' or @User1<>'high'
BEGIN
THROW 51000, 'The record does not exist.', 1;
END
//do something here
END
GO;
Does this work for you?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yusuf Ganiyu |
