外贸网站平台seo推广,c做网站,中国十大科技公司,wordpress网页折叠效果Access和sql server的语法区别 一、有区别的函数及解决方案 以下所示的解决方案中的函数定义在untDataBase单元中TAdoConn类的方法中。 序号简述Access语法SqlServer语法Oracle语法DB2语法解决方案01系统时间Date()GETDATE()SYSDATE GetSysTimeStr02连接字符串||GetConcat…Access和sql server的语法区别 一、有区别的函数及解决方案 以下所示的解决方案中的函数定义在untDataBase单元中TAdoConn类的方法中。 序号简述Access语法SqlServer语法Oracle语法DB2语法解决方案01系统时间Date()GETDATE()SYSDATE GetSysTimeStr02连接字符串||GetConcatStr03截取字符串SubStringSubStrSubStringSubStringGetSubStr04小写字符串LCaseLowerLowerLowerGetLowerStr05大写字符串UCaseUpperUpperUpperGetUpperStr06查找字符串InStrInStrCharIndexInStrGetFindStr07替换空值IIFIsNullCoalesceNvlCoalesceGetNullStr08条件取值IIFCaseWhenElseDeCode或CaseIIFGetCaseStr09字段类型转换Str、var、….Convert或castTo_Char,To_Number.GetConvertStrGetConvertStr10日期字符串‘2004-10-9’#2004-10-19#‘2004-10-9’ GetDateStr11最大值加1 GetNextNumStr12Like语句函数Like ‘101*Like ‘101%’Like ‘101%’ GetLikeStr 二、Access与SQLSERVER部分相同数据库函数及关键字列表 1、 函数 序号 简述 01记数函数 Count02最大值Max 2、 关键字 序号 简述 01Like02连接Join03判断空Is Null 三、Access与语句SqlServer的语句语法区别 1、 Inser Into …..Select …From 语句 在ACCESS中以下语句 Insert INTO PubSubJectAccCopys(Copy_id,Acc_id,Acc_Pid,Acc_name,acc_short,Acc_Comment,Acc_Pro,acc_type,Sub_id_flag,acc_index) (Select 200201,Acc_id,Acc_Pid,Acc_name,acc_short,Acc_Comment,Acc_Pro,acc_type,Sub_id_flag,acc_index FROM PubSubJectAcc Where PubSubJectAcc.co_type03) 中后面(select 200201******.co_Type03)中的小括号((,))必须去掉才能执行如下 Insert INTO PubSubJectAccCopys(Copy_id,Acc_id,Acc_Pid,Acc_name,acc_short,Acc_Comment,Acc_Pro,acc_type,Sub_id_flag,acc_index) Select 200201,Acc_id,Acc_Pid,Acc_name,acc_short,Acc_Comment,Acc_Pro,acc_type,Sub_id_flag,acc_index FROM PubSubJectAcc Where PubSubJectAcc.co_type03 在SQL SERVER 中都可以 2、 Inner Join 语句1 StrSql:select a.user_id,a.user_opcode,b.copy_name from sysuser a inner join (syscopysuser c inner join syscopys b on c.copy_idc.copy_id) on a.user_idc.user_id where a.user_opcode EdtUserOpCode.text And copy_nameTmpcopyname ; 应该改为 StrSql:select a.user_id,a.user_opcode,b.copy_name from sysuser a inner join (syscopysuser c inner join syscopys b on c.copy_idd.copy_id) on a.user_idc.user_id where a.user_opcode EdtUserOpCode.text And copy_nameTmpcopyname ; 该行代码的检索条件错误应该把C.copy_idC.Copy_id 改为c.copy_idd.copy_id 注两种写法都能在SQL-SERVER中运行但c.copy_idC.copy_id在ACCESS中不能运行 3、 Inner Join 语句2 StrSql:select copy_year,copy_name,a.copy_id from SysCopys a inner join SysCopysUser b on a.curcopy_flag1 and a.copy_idb.copy_id where b.user_id TmpPubUserID ; 该为 StrSql:select copy_year,copy_name,a.copy_id from SysCopys a inner join SysCopysUser b on a.copy_idb.copy_id where a.curcopy_flag1 and b.user_id TmpPubUserID ; 注两种写法都能在SQL-SERVER中运行但第一种在ACCESS中不能运行 4、 Inner Join语句3 SQl server 中可以执行以下语句 Select distinct sysoption.opti_id,sysoption.opti_name,sysoption.opti_code,sysroleoption.opti_sort From sysoption inner join sysroleoption ON sysoption.opti_idsysroleoption.opti_id AND sysroleoption.role_id:roleid 但ACCESS中不能只能 Select distinct sysoption.opti_id,sysoption.opti_name,sysoption.opti_code,sysroleoption.opti_sort From sysoption inner join sysroleoption ON sysoption.opti_idsysroleoption.opti_id Where sysroleoption.role_id:roleid 5、 Update语句 Sql SerVer 中能执行但Access 中不能 Update sysuserrole SET sysuserrole.role_sort (Select sysrole.role_sort FROM sysrole Where sysuserrole.role_id sysrole.role_id and sysuserrole.user_id01) 6、 日期比较 SQL SERVER 中用 StrSql:select copy_year,Start_month,Cur_month,Start_Flag,Start_date,End_date From SysCopys where copy_idLoginCopyID and start_datedatetostr(LoginDate) and end_datedatetostr(LoginDate); ACCESS中用 StrSql:select copy_year,Start_month,Cur_month,Start_Flag,Start_date,End_date From SysCopys where copy_idLoginCopyID and start_date#datetostr(LoginDate)# and end_date#datetostr(LoginDate)# 参考以上的第10个函数“GetDateStr” 7、 最大数值获取语句 StrSql:insert into sysRoleOption select fidRoleId as Role_ID,opti_id, convert(numeric,opti_id)-(convert(numeric,opti_parentid)*100) MaxOptiSort as opti_Sort from sysoption where opti_parentid PCoTypeID(self.trvRoles.Selected.data)^.StrCoTypeID and opti_bottom1; 改为 StrSql:insert into sysRoleOption select fidRoleId as Role_ID,opti_id, opti_id-opti_parentid*100 MaxOptiSort as opti_sort from sysoption where opti_parentid PCoTypeID(self.trvRoles.Selected.data)^.StrCoTypeID and opti_bottom1 注两种写法都能在SQL-SERVER中运行但第一种在ACCESS中不能运行 但是考虑会出现Null值以及语句的通用性可以使用以上的第07个函数“GetNullStr”和第09个函数“GetConvertStr”来完成字符串向数字空值和0数字的转换参考GetNextNumStr代码。 1、Sql中不能省略as 2、一次只能执行一条Sql 3、没有substring、cast等函数 4、sql中严格区分整形和字符型 5、没有存储过程、触发器 6、 替换为 7、时间字符串两边加#号8、带参数的sql语句中 用?号替换