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

access与SqlServer 之时间与日期及其它SQL语句比较

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 table where data=datediff(day,fixdate,getdate())
1.2算出时间差:
1.access:       datediff('h',fixdate,getdate())
2.sqlserver:    datediff(Hour,'2004-12-10',getdate())
ACCESS实例:    select DATEDIFF('h',HMD,getdate())
sqlserver实例: select datediff(Hour,'2004-12-10',getdate())
1.3算出月份差:
1.access:       datediff('m',fixdate,getdate())
2.sqlserver:    datediff(Month,'2004-12-10',getdate())
ACCESS实例:    select DATEDIFF('m',HMD,getdate())
sqlserver实例: select datediff(Month,'2004-12-10',getdate())
----------------------------------------------------------------------------
2、日期变量
1.access:       #"&data&"#
2.sqlserver:    '"&data&"'
ACCESS实例:    select * from table where data=#"&data&"#
sqlserver实例: select * from table where data='"&data&"'
----------------------------------------------------------------------------
3、是否
1.access:       not finished
2.sqlserver:    finished=0
ACCESS实例:    select * from table where not finished
sqlserver实例: select * from table where finished=0
----------------------------------------------------------------------------
4、求余数
1.access:       a mod b=100
2.sqlserver:    a % b =100
ACCESS实例:    select   a mod b=100 from table where not finished
sqlserver实例: select a % b =100 from table where finished=0
-----------------------------------


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

SQl 语句(常见) 新建,删除,修改表结构

新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......

SQL只取日期的年月日部分


方法一:
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 server存储过程中 数据集的缓存

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 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号