当前位置: 代码迷 >> SQL >> 日前工作中遇到的SQL语句
  详细解决方案

日前工作中遇到的SQL语句

热度:37   发布时间:2016-05-05 10:09:04.0
最近工作中遇到的SQL语句

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


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

  相关解决方案