验证sql中的整数 [英] Validate integer in sql
本文介绍了验证sql中的整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个数据库表DeleteRecords,其中我有一个字段''NoOfDays''。我需要验证NoOfDays列值是否为正非零整数(只有整数而不是浮点数)。
Hi all,
I have a database table DeleteRecords in which i have a field ''NoOfDays''. I need to validate that the NoOfDays column value is a positive non zero integer (only integer not a float number).
DECLARE @noofdays INT
SELECT @noofdays = NoOfDays
FROM DeleteRecords
WHERE RecordsID = 1
我需要检查@noofdays是否为正非零整数
请帮忙。
提前致谢。
I need to check if @noofdays is a positive non zero integer
Please help on this.
Thanks in advance.
推荐答案
检查这个...
Check this...
declare @noofdays int
set @noofdays = -1
select case when @noofdays <= 0 then 'invalid' else 'valid' end as verification
快乐编码!
:)
Happy Coding!
:)
这篇关于验证sql中的整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文