SQL函数
- Dateadd('d',-3,now); ---函数返回的值是当前时间加上(-2)天的值
SQL函数大全---
一)字符转换函数:
- ASCII()
- CHAR()
- LOWER() / UPPER()
- STR()
二)去空格函数:
- LTRIM()
- RTRIM()
三)取子串函数:
- LEFT()
- RIGHT()
- SUBSTRING()
四)字符串比较函数:
- CHARINDEX()
- PATINDEX()
五)字符串操作函数:
- QUOTENAME()
- REPLICATE()
- REVERSE()
- REPLACE()
- SPACE()
- STUFF()
六)数据类型转换函数:
- CAST()
- CONVERT()
七)日期函数:
- DAY()
- MONTH()
- YEAR()
- DATEADD()
- DATEDIFF()
- DATENAME()
- DATEPART()
- GETDATE()
八)聚合函数:
- SUM()
- COUNT()
- MAX()
- AVG()
- STDEV()
- STDEVP()
- VAR()
- VARP()
九)数学函数表:
- ASIN,ACOS,ATAN
- ATN2
- SIN,COS,TAN,COT
- DEGREES
- RADIANS
- EXP
- POWER
- SQRT
- LOG
- LOGIO
- ABS
- GEILING
- FLOOR
- RAND
- PI
- ROUND
- SIGN
十)系统函数表:
- COL_NAME
- COL_LENGTH
- curunreserve
- dpgs
- data_pgs
- datalength
- db_id
- db_name
- host_id
- host_name
- index_col
- isnull
- lct_admin
- reserved_pgs
- rowent
- object_id
- object_name
- suser_id
- tsequal
- used_pgs
- user
- user_name
- valid_name
- valid_user
十一)全局变量:
- APP_NAME()
- @@ERROR
- @@IDENTITY
- USER_NAME()
- @@CONNECTIONS
- GETDATE()
- @@CPU_BUSY
- @@DBTS
- @@IDLE
- @@IO_BUSY
- @@LANGID
- @@LANGUAGE
- @@LOCK_TIMEOUT
- @@MAX_CONNECTIONS
- @@MAX_PRECISION
- @@OPTIONS
- @@PACK_RECEIVED
- @@PACK_SENT
- @@PACKET_ERRORS
- @@SERVERNAME
- @@SERVICENAME
- @@TIMETICKS
- @@TOTAL_ERRORS
- @@TOTAL_READ
- @@TOTAL_WRITE
- @@TRANCOUNT
- @@VERSION
补充:
- 问:如何将sql数据库中一列中的值复制到另一列? ---update a_table set money=age where 1=1;
- 查询两个日期(时间)以内的数据,between and 或 and 连>= <=,to_date(),如下:
between and 方法
- select * from kk.kkhmd where larq between(to_date('2008-9-3','yyyy-mm-dd')) and (to_date('2008-9-5','yyyy-mm-dd'))
select * from kk.kkhmd where larq between(to_date('2008-9-3','yyyy-mm-dd')) and (to_date('2008-9-5','yyyy-mm-dd'))
用and连接 >= <= 方法
- select * from kk.kkhmd where larq>=to_date('2008-9-3','yyyy-mm-dd') and larq <=to_date('2008-9-5','yyyy-mm-dd')
select * from kk.kkhmd where larq>=to_date('2008-9-3','yyyy-mm-dd') and larq <=to_date('2008-9-5','yyyy-mm-dd')