sql server 系统函数用法实例

系统函数
1.case when ... then ..else ..end(用于对条件进行测试)


e.Select id,case when name='deepwishly' then '老大' else '其他' end as Type
 显示 id  type
          1   老大


2.cast()/convert() 前者具有ANSI SQL-92兼容性,后者功能更强大
e, cast(variable_or_column As datatype);convert(datatype,varialbe_or_column)

 

3.isdate()判断是否是有效的日期或时间,测试日期格式必须与使用 set dateformat or set language设定的格式具有相同的地域格式
e, select isdate(varialbe_or_column)//是有效日期返回1否则返回0

 

4.isnull() 判断是否是null
isnull(value_to_test,new_value)
e,替换数据库或变量中null为某值,select isnull(variable_or_column,new_value)

 

5.isnumeric()判断是否是数字 返回0,false或1,true
e,select(variable_or_colunn)

你可能感兴趣的:(sql,数据库,server,测试,null)