个人开发历程知识库

关注C++/Java/C#技术, 致力于安防监控/移动应用/WEB方面开发
------------------------------------ 业精于勤,荒于嬉;行成于思,毁于随
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Access 2003 与 SQL Server 2000 [SQL书写方面差异]

Posted on 2009-07-03 11:10  peterzb  阅读(1215)  评论(0编辑  收藏  举报

    读大学时候写的, 现从CSDN博客中转移过来到这边.

MS SQL Server 2000 与 Access 2003 SQL[ANSI89/92]语言使用的区别:在使用这两种数据库时候,发觉它们差别还是比较大的,总结了几点出来

数据库技术我采用ADO.NET来访问MS SQL 2000  [开发平台用vs 2003],
采用ADO 2.6来访问Access 2003 [开发平台用vb 6.0]测试


1.支持的数据类型不同
MS SQL 2000                      Access 2003
varchar(0-8000)                  text(0-255)
int/bigint                             integer/数字
long                                    数字
标识位                                 自动编号
bit(0/1)                               是/否(true/false)
text                                    备注[好像只有4k容量]
DateTime                             日期[Date],时间[Time],日期时间
image                                  ole对象
2.关键字
id,name,user在MS Server 2000的sql中都是关键字,使用时需[id],[name]
而在access中不是
3.语句
A.
select 'username'=a from table1
ms server 2000支持          Access不支持
select a as username from table1
ms server 2000支持          Access 2003支持 
B.
insert table1 values('a',1)
ms server 2000支持          Access不支持
insert into table1(c1,c2) values('a',1)
ms server 2000支持          Access 2003支持 
C.
delete table1 where [id]=1
ms server 2000支持          Access不支持
delete from table1 where [id]=1
ms server 2000支持          Access 2003支持 
D.
bool类型的列更改数据
ms server 2000
update t1 set c2=1 where [id]=1
Access 2003
update t1 set c2=true where id=1
4.内置函数
MS Sql Server 2000       Access 2003
substring                            mid
len                                      len
trim                                    trim
left                                      left
right                                    right
getDate                               now
...                                          ...