TSQL:检查 varchar 是否可以转换为数字
我正在尝试测试变量的值是否可以转换为数值.
I'm trying to test whether the value of the variable can be converted to a numeric value.
DECLARE @var1 VARCHAR(50)
SET @var1 = '1'
IF(ISNUMERIC(@var1) = 1)
BEGIN
PRINT 'It's numeric'
END
到目前为止,我什么都不赌.我错过了什么吗?
So far, I'm betting nothing. Am I missing anything?
推荐答案
您的打印语句中存在引用问题
you've got a quoting issue in your print statement
DECLARE @var1 VARCHAR(50)
SET @var1 = '1'
IF(ISNUMERIC(@var1) = 1)
BEGIN
PRINT 'It is numeric'
END
相关文章