当前位置:Gxlcms > 数据库问题 > 最近工作中遇到的SQL语句

最近工作中遇到的SQL语句

时间:2021-07-01 10:21:17 帮助过:16人阅读

1.求表中某列的和,并把其值赋给一个变量:


SqlCommand cmd = new SqlCommand( "select sum(aa) from table ", conn); 

Int32 aa= (Int32) cmd.ExecuteScalar(); 

2.判断字段的值是否为数字


select * from hr_user where isnumeric(usid)=1//为数字
select * from hr_user where isnumeric(usid)=0//不为数字

3.数据表Rex_Test3中 字段【UserName】中 包含 字符【R】 的数据集
select * from Rex_Test3 where charindex('R',UserName)>0

数据表Rex_Test3中 字段【UserName】中 不包含 字符【R】 的数据集
select * from Rex_Test3 where charindex('R',UserName)=0


版权声明:本文为博主原创文章,未经博主允许不得转载。

最近工作中遇到的SQL语句

标签:

人气教程排行