This article briefly summarizes the syntactic differences between access and sql server. I hope it will be helpful to everyone.
1. Differentiated functions and solutions
The functions in the solution shown below are defined in the method of the TAdoConn class in the untDataBase unit.
2. Database functions and keyword lists that are partially the same between Access and SQLSERVER
1. Functions
2. Keywords
3. The difference in statement syntax between Access and statement SqlServer
1. Inser Into…..Select…From statement:
The following statement in 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_type='03')
中后"(select 200201******.co_Type=' 03')" must be removed to execute, as follows:
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_type='03'
In SQL SERVER Medium All are OK
2. Inner Join statement 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_id=c.copy_id) on a.user_id=c.user_id where
a.user_opcode=''' EdtUserOpCode.text ''' And copy_name=''' Tmpcopyname '''';
should be changed to
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_id=d.copy_id) on a.user_id=c.user_id where
a.user_opcode=''' EdtUserOpCode.text ''' And copy_name=''' Tmpcopyname '''';
Retrieval of this line of code Condition error: C.copy_id=C.Copy_id should be changed to c.copy_id=d.copy_id
Note: Both writing methods can run in SQL-SERVER, but c.copy_id=C.copy_id is Cannot run in ACCESS
3. Inner Join statement 2
StrSql:='select copy_year,copy_name,a.copy_id from SysCopys a inner join SysCopysUser b on a.curcopy_flag=1 and a. copy_id=b.copy_id where b.user_id=' '''' TmpPubUserID '''';
This is
StrSql:='select copy_year,copy_name,a.copy_id from SysCopys a inner join SysCopysUser b on a.copy_id=b.copy_id where a.curcopy_flag=''1'' and b.user_id=' '''' TmpPubUserID '''';
Note: Both writing methods are It can run in SQL-SERVER, but the first one cannot run in ACCESS
4. Inner Join statement 3
The following statement can be executed in SQl server
'Select distinct sysoption.opti_id,sysoption.opti_name,sysoption.opti_code,sysroleoption.opti_sort From sysoption inner join sysroleoption ON sysoption.opti_id=sysroleoption.opti_id AND sysroleoption.role_id=:roleid'
But not in ACCESS, only
'Select distinct sysoption.opti_id,sysoption.opti_name,sysoption.opti_code,sysroleoption.opti_sort From sysoption inner join sysroleoption ON sysoption.opti_id=sysroleoption.opti_id Where sysroleoption.role_id=:roleid'
5. Update statement
Can be executed in Sql SerVer but not in Access
'Update sysuserrole SET sysuserrole.role_sort = (Select sysrole.role_sort FROM sysrole Where sysuserrole.role_id = sysrole.role_id and sysuserrole.user_id='01')'
6. Date comparison
Used in SQL SERVER
StrSql:='select copy_year,Start_month,Cur_month,Start_Flag,Start_date, End_date '
'From SysCopys '
'where copy_id=''' LoginCopyID ''' '
'and start_date
'and end_date>=''' datetostr(LoginDate) '''';
Used in ACCESS
StrSql:='select copy_year,Start_month,Cur_month ,Start_Flag,Start_date,End_date '
'From SysCopys '
'where copy_id=''' LoginCopyID ''' '
'and start_date
'and end_date>=#' datetostr(LoginDate) '#'
Refer to the 10th function "GetDateStr" above
7. Maximum value acquisition statement
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_bottom=''1' '''';
Change for
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_bottom='' 1' ''''
Note: Both writing methods can be run in SQL-SERVER, but the first one cannot be run in ACCESS
But consider that Null values and statements will appear For versatility, you can use the 07th function "GetNullStr" and the 09th function "GetConvertStr" above to complete the conversion of strings to numbers, null values and 0 numbers: refer to the GetNextNumStr code.
1. As cannot be omitted in Sql
2. Only one Sql can be executed at a time
3. There are no substring, cast and other functions
4. Strictly distinguish between integer and character types in SQL
5. No stored procedures or triggers
6.! = is replaced with
7. Add # signs on both sides of the time string
8. In the sql statement with parameters, replace @ with ? sign
Related recommendations: access database tutorial
The above is the detailed content of Syntax comparison between access and sql server. For more information, please follow other related articles on the PHP Chinese website!

Access 验证规则是一种数据验证工具,用于确保数据符合特定条件,防止输入无效数据。设置验证规则的步骤:1. 选择要设置验证规则的字段;2. 打开“字段属性”对话框并切换到“查找”选项卡;3. 在“验证规则”字段中输入验证规则;4. 在“验证文本”字段中输入不符合规则时的错误消息;5. 单击“确定”保存更改。

microsoft access是由微软发布的关系数据库管理系统;它结合了MicrosoftJet Database Engine和图形用户界面两项特点,是Microsoft Office的系统程序之一。

Access 数据库文件的扩展名为 .accdb,自 Microsoft Access 2007 起开始使用,用于识别包含结构化数据的容器文件,如表、查询和窗体。

access和trunk端口的区别:1、Access端口用于连接终端设备,提供单个VLAN的接入,而Trunk端口用于连接交换机之间,提供多个VLAN的传输;2、Access端口只传输属于指定VLAN的数据,而Trunk端口可以传输多个VLAN的数据,并使用VLAN标签进行区分。

将 Excel 数据导入 Access 的步骤:1. 打开 Access 数据库。2. 创建链接的表,选择 Excel 工作簿。3. 选择 Excel 表格。4. 映射字段。5. 选择数据选项。6. 导入数据。7. 管理链接的数据。

vb中连接access数据库的步骤包括引用必要的命名空间、创建连接字符串、创建连接对象、打开连接、执行SQL语句和关闭连接。详细介绍:1、引用必要的命名空间,在VB项目中,首先需要引用“System.Data`和`Microsoft.Office.Interop.Access”命名空间,以便使用ADO.NET和Access相关的类和方法,可以在VB项目的引用中添加这些命名等等。

Microsoft Access 是一款关系型数据库管理系统 (RDBMS),用于存储、管理和分析数据。它主要用于数据管理、导入/导出、查询/报表生成、用户界面设计和应用程序开发。Access 优势包括易用性、集成数据库管理、强大灵活、与 Office 集成和可扩展性。

Microsoft Access 是一款用于创建、管理和查询数据库的关系型数据库管理系统,提供以下功能:数据存储和管理数据查询和检索表单和报表创建数据分析和可视化关系数据库管理自动化和宏多用户支持数据库安全可移植性


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
