ACCESS改为SQL需要注意哪几个地方

来源:互联网 发布:文明5 mac 汉化 编辑:程序博客网 时间:2024/05/18 18:21
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

看到别人有时问这个方面的问题。。于是在各网站总结前前辈高人的几点想法,拿来共享:

数据库导入以后,自动增加字段需要重写,所有的数字类型需要增加长度,最好用decimal。

所有的默认值都丢失了。主要是数字类型和日期类型。

所有now(),time(),date()要改成getdate()。

所有datediff('d', time1, time2)要改成datediff(day, time1, time2)

有可能一些true/false类型不能使用,要变为1/0。

备注类型要通过cast(column as varchar)来使用。

CursorType要改成1,也就是打开数据库时要给出第一个数字参数为1,否则记录可能显示不完整。

isnull(rowname)要改成rowname = null

ACCESS的数据库中的自动编号类型在转化时,SQL server并没有将它设为自动编号型,我们需在SQL创建语句中加上identity,表示自动编号!

转化时,跟日期有关的字段,SQL SERVER默认为smalldatetime型,我们最好将它变为datetime型,因为datetime型的范围比smalldatetime型大。有时用smalldatetime型时,转化失败,而用datetime型时,转化成功。

对此两种数据库进行操作的SQL语句不全相同,例如:在对ACCESS数据库进行删除纪录时用:"delete * from user where id=10",而对SQL SERVER数据库进行删除是用:"delete user where id=10".

日期函数不相同,在对ACCESS数据库处理中,可用date()、time()等函数,但对SQL SERVER数据库处理中,只能用datediff,dateadd等函数,而不能用date()、time()等函数。

在对ACCESS数据库处理中,SQL语句中直接可以用一些VB的函数,像cstr()函数,而对SQL SERVER数据库处理中,却不能用。<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>