易截截图软件、单文件、免安装、纯绿色、仅160KB

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中 in 、not in 、exists、not exists 用法和差别

exists (sql 返回结果集为真)
not exists (sql 不返回结果集为真)
如下:
表A
ID NAME
1    A1
2    A2
3  A3
表B
ID AID NAME
1    1 B1
2    2 B2
3    2 B3
表A和表B是1对多的关系 A.ID => B.AID
......

How To Use Dynamic Sql in Sql Server ?

How To Use Dynamic Sql in Sql Server ?
 
动态SQL 在sql server Procedure中的应用
 
 
Create PROCEDURE [dbo].[Proc_Get_Serial_No]
        (
         @Table_Name varchar(20),
      ......

Sql函数大全

--聚合函数
use pubs
go
select avg(distinct price)  --算平均数
from titles
where type='business'
go
use pubs
go
select max(ytd_sales)  --最大数
from titles
go
use pubs
go
select min(ytd_sales) --最小数
from titles
go
use pubs
go
select type,sum(price),sum(advance)  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号