SQL 获取当前日期,年、月、日、周、时、分、秒
select GETDATE() as '当前日期',
DateName(year,GetDate()) as '年',
DateName(month,GetDate()) as '月',
DateName(day,GetDate()) as '日',
DateName(dw,GetDate()) as '星期',
DateName(week,GetDate()) as '周数',
DateName(hour,GetDate()) as '时',
DateName(minute,GetDate()) as '分',
DateName(second,GetDate()) as '秒'
结果:
2009-12-19 15:23:50.530 2009 12 19 星期六 51 15 23 50
相关文档:
--当前使用的数据库是 系统自带的 master
create database temp1
go --此处不加go的话下面use temp1 会报错:找不到存储过程 'temp1'。
use temp1
set xact_abort on
begin tran
create table [order]( --order是关键字必须用[ ];
id int
)
create table fOrder(
id int
)
-- 下面的操作主要是为了实现fO ......
create procedure DeleteWareHouse_StoreArea_SummaryByPUR
(@po_no nvarchar(100))
as
begin
declare @cacheTable table(wh_id int);--声明一个table类型的变量
insert @cacheTable select wh_id from aps_inventory_store_area where description=@po_no--向变量@cacheTable中添加结果集
--select * from @cac ......
1。select * from v$nls_parameters
查询nls的参数,获得数据库服务器端的字符编码
NLS_LANGUAGE
NLS_CHARACTERSET
2。修改本地环境变量,设置
NLS_LANG = SIMPLIFIED CHINESE.ZHS16GBK //这个是我们的数据库字符编码
NLS_LANG格式:
NLS_LANG = language_territory.char ......
1、Datediff:
1.1算出日期差:
1.access: datediff('d',fixdate,getdate())
2.sqlserver: datediff(day,fixdate,getdate())
ACCESS实例: select * from table where data=datediff('d',fixdate,getdate())
sqlserver实例: select * from ......
1、SELECT 查询语句和条件语句
SELECT 查询字段 from 表名 WHERE 条件
查询字段:可以使用通配符* 、字段名、字段别名
表名: 数据库.表名 ,表名
常用条件: = 等于 、<>不等于、in 包含 、 not in 不包含、 like 匹配
BETWEEN 在范围 、 not BETWEE ......