I've a query like below:-
DECLARE @rptID VARCHAR(8)
SET @rptID = (SELECT reportID FROM Reports)
In general @rptID contains numeric digits like '00001234' etc. But is there any way to validate if the variable @rptID contains any non-numeric value in it.
For ex.
IF (@rptID contains non-numeric value)
THEN throw Error
Check for any characters that are not in the range 0 to 9
IF @rptID LIKE '%[^0-9]%'
--throw error