You can write a function: mainly using rules to judge. In addition, if the input character is empty, replace it with “-“.
CREATE FUNCTION [dbo].[svf_NonNegativeInteger] ( @val NVARCHAR(4000) ) RETURNS BIT AS BEGIN DECLARE @rtv BIT = 1 SET @val = ISNULL(LTRIM(RTRIM(@val)), N'-') IF @val LIKE '%[^0-9]%' OR @val = N'' SET @rtv = 0 ELSE SET @rtv = 1 RETURN @rtv END
Examples show that:
Above is the example code of MYSQL custom function which is introduced to you by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message for me, Xiaobian will reply to you in time. Thank you very much for your support to developpaer.