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
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
方法一:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),\'-\',\'\'),\' \',\'\'),\':\',\'\')
20040912110608 h
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 11 ......
系统要求进行SQL优化,对效率比较低的SQL进行优化,使其运行效率更高,其中要求对SQL中的部分in/not in修改为exists/not exists
修改方法如下:
in的SQL语句
SELECT id, category_id, htmlfile, title, convert(varchar(20),begintime,112) as pubtime
from tab_oa_pub WHERE is_check=1 and
category_id in (sel ......
党员管理系统的数据库设计
需要以下字段:
l 学生:
//学生基本信息
u 学生学号[id](char)主键
u 学生身份证号[id_num](char)
u 学生姓名[name](char)
u 学生出生日期[born_date](date)
u 学生籍贯[native](int)外键
u 学生家庭住址[address](char)
u&nbs ......
通常执行sql语句,大家用的都是exec,exec功能强大,但不支持嵌入参数,sp_executesql解决了这个问题。抄一段sqlserver帮助:
sp_executesql
执行可以多次重用或动态生成的 Transact-SQL 语句或批处理。Transact-SQL 语句或批处理可以包含嵌入参数。
语法
sp_executesql
[@stmt
=
] stmt
[
&n ......