Professional Documents
Culture Documents
Delphi - Connect To Microsoft SQL Server (FireDAC) - RAD Studio
Delphi - Connect To Microsoft SQL Server (FireDAC) - RAD Studio
Supported Versions
The FireDAC native driver supports Microsoft SQL Server Standard and Express editions version 2000 and later, and Contents
Microsoft SQL Azure. For a description of how to connect to Microsoft SQL Server Compact Edition, see Connect to Supported Versions
Microsoft SQL Server Compact Edition. Client Software
Windows Client Software
macOS Client Software
Client Software Linux Client Software
Driver Linkage
Windows Client Software Connection Definition Parameters
FireDAC requires one of the Microsoft SQL Server x86 or x64 ODBC drivers to be installed on the workstation: Use Cases
Using a Secure Connection
▪ SQL Server ODBC driver as the connectivity for SQL Server 2000. Most likely, the ODBC driver is already installed on Other Use Cases
your workstation. If not, see details (https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-serv
See Also
er?view=sql-server-ver16).
Samples
▪ SQL Native Client as the connectivity for SQL Server 2000 and 2005. We strongly recommend that you have SQL
Native Client installed, if your application has to work with SQL Server 2005. See Microsoft SQL Server Native Client (htt
ps://learn.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client?view=sql-server-ver15).
▪ SQL Server Native Client NN.N as the connectivity for SQL Server 2000, 2005, 2008, 2012, and SQL Azure. We strongly recommend that you have SQL Server
Native Client NN.N installed, if your application has to work with SQL Server 2008, 2012, or SQL Azure. See Microsoft SQL Server 2008 Native Client (https://www.mi
crosoft.com/en-us/download/details.aspx?id=57606).
▪ SQL Server Native Client 11.0 as the connectivity for LocalDB.
▪ ODBC Driver 13-18 as the connectivity for SQL Server 2008, 2008 R2, 2012, 2014, 2016, 2017, and 2019 and SQL Azure. We recommend using ODBC Driver 18.
Note: SQL Server Native Client 10.0 (SQL Server 2008) may fail to call a stored procedure when connected to SQL Server 2000.
The symptom of this issue is the error message "Incorrect Syntax near to {". In this case, use the ODBC driver from the SQL Server
2000 or 2005 distribution.
If the SQL Server ODBC driver has not been installed properly, an exception is raised when you try to connect:
[FireDAC][Phys][ODBC][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Note that you may also need to install the gawk utility. At this point, you can con�gure a ODBC DSN or test the FireDAC connection.
Note that the FreeTDS ODBC driver is not that e�cient and stable as the original Microsoft ODBC driver.
2. On Red Hat Enterprise Linux 7, download the corresponding installer (https://www.microsoft.com/en-us/download/details.aspx?id=36437) and follow the official
installation instructions (https://msdn.microsoft.com/en-us/library/hh568454%28v=sql.110%29.aspx#Anchor_1).
Driver Linkage
To link the driver:
DriverID=MSSQL
Parameter Description Example value
Server Name of a server running SQL Server on the network. The value must be
either the name of a server on the network or the name of a SQL Server ▪ 127.0.0.1\SQLEXPRESS
Client Network Utility advanced server entry. ▪ SrvHost, 4000
When you connect to the SQL Azure, you have to prepend the server name with the "tcp:" ▪ tcp:nasdfert6.database.windows.net
prefix.
Port Only for macOS. Specifies the port where the SQL Server is listening.
For the Windows platform the port may be specified after a comma in the Server
parameter value. For example, Server=host, port. The default port is 1433.
Database Name of the default database for the connection. If the Database is not Northwind
specified, the default database defined for the login is used.
OSAuthent Controls the authentication mode: No
Network Name of a network library dynamic-link library. The name does not need to dbnmpntw
include the path and must not include the .dll file name extension.
Address Network address of the server running an instance of SQL Server.
Address is usually the network name of the server, but can be other
names, such as a pipe, or a TCP/IP port and socket address.
MARS Controls the MARS (multiple active result sets) support in a connection: No
For information about MARS, see: Using Multiple Active Result Sets (MARS) (http://msd
n.microsoft.com/en-us/library/ms131686.aspx)
Workstation Workstation ID. Typically, this is the network name of the computer on Bookkeeper1
which the application resides (optional). If specified, this value is stored in
the master.dbo.sysprocesses column hostname and is returned by sp_who
and the Transact-SQL HOST_NAME function.
Language SQL Server language name (optional). When connecting to a SQL Server
with multiple languages, Language specifies which set of messages are
used for the connection.
Encrypt Controls the network traffic encryption: Yes
Use Cases
Using a Secure Connection
To use TLS/SSL encryption, pass the key-value pair TrustServerCertificate=yes on the value of the O DBCAdvanced parameter:
ODBCAdvanced=TrustServerCertificate=yes
DriverID=MSSQL
Server=127.0.0.1
Database=Northwind
User_Name=sa
MetaDefSchema=dbo
MetaDefCatalog=Northwind
DriverID=MSSQL
Server=DA\SQLEXPRESS
Database=Northwind
OSAuthent=Yes
MARS=no
▪ Connect to SQL Azure. Note the "@<server>" suffix in User_Name and the "tcp:" prefix in the Server parameters:
DriverID=MSSQL
Server=tcp:nasdfert6.database.windows.net
Database=Northwind
User_Name=addemo@nasdfert6
Password=asd123zxc
Encrypt=Yes
MetaDefSchema=dbo
MetaDefCatalog=Northwind
▪ Connect to LocalDB:
DriverID=MSSQL
Server=(localdb)\\v11.0
Database=master
OSAuthent=Yes
Server=(localdb)\\v11.0
DriverID=MSSQL
ODBCAdvanced=AttachDbFileName=C:\\Users\\Alex\\ADDemo.mdf
See Also
▪ Common Connection Parameters
▪ FAQs
▪ How to configure FireDAC Drivers
▪ How to manage FireDAC Connection Definitions
Samples
▪ FireDAC MS SQL sample