TDS Server: Use Transact-SQL (T-SQL) statements to work with Salesforce data in SQL Server
The Easysoft Salesforce ODBC driver allows you to access Salesforce from SQL Server through the linked server mechanism. You can then use T-SQL, OPENQUERY
, or EXEC
to query and update your Salesforce data. Because this linked type uses ODBC, a generic interface, SQL Server behaves differently when you use T-SQL than it would if the linked server was another SQL Server instance. For example, if you run a query with a character column in a WHERE
clause such as:
SELECT * FROM SALESFORCE.SF.DBO.Account WHERE Id = '0010H00002pXxj6QAC'
SQL Server will first remove the WHERE
clause, send SELECT * FROM SALESFORCE.SF.DBO.Account
to Salesforce (with consequent implications for performance and Salesforce API usage) and then filter the result set locally.
TDS Server enables you to take advantage of the T-SQL optimisations afforded by a native linked server whilst retaining the non-native data access.
To SQL Server, TDS Server is another SQL Server instance. To the Salesforce ODBC driver, TDS Server is an ODBC application. The components are:
SQL Server <-> TDS Server <-> Salesforce ODBC Driver <-> Salesforce
TDS Server is bundled with the Server edition of the Salesforce ODBC driver.
Salesforce ODBC driver configuration
- Install and license the Salesforce ODBC driver on the machine where SQL Server is installed.
For installation and licensing instructions, refer to the Salesforce ODBC driver manual.
Before you can use the Salesforce ODBC driver to connect your application to Salesforce, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (in this case, Salesforce) and the ODBC driver that's required to connect to it (in this case, the Salesforce ODBC driver).
To run ODBC Data Source Administrator (which you use to create a data source), in the Windows Run dialog box, enter this command:
%windir%\system32\odbcad32.exe
To create a Salesforce ODBC driver data source:
- In ODBC Data Source Administrator, choose the System DSN tab, and then choose Add.
- In the Create New Data Source dialog box, choose Easysoft Salesforce ODBC driver, and then choose Finish.
Note Complete the configuration dialog as directed in the next step. You also need to turn off the Custom Null option.
- Complete the DSN Setup dialog box:
Setting Value DSN Salesforce User Name The name of your Salesforce user. For example, myuser@mydomain.com
.Password The password for your Salesforce user. Token The security token for your Salesforce user, if required. To find out whether you need to supply a security token, choose the Test button. If the connection attempt fails with an error which contains
LOGIN_MUST_USE_SECURITY_TOKEN
, you need to supply one.Salesforce emails the security token to the email address associated with your Salesforce user account. If you have not received a security token, you can regenerate it. Salesforce will then email the new security token to you. To regenerate your security token, log in to Salesforce and then choose Setup from the user menu. Search for "security token" in the Quick Find box. Choose Reset Security Token in the Reset Security Token page. When you receive the token in your email client, copy it and then paste it into the Token field.
- Use the Test button to verify that you can successfully connect to Salesforce.
TDS Server configuration
Obtain the TDS Server distribution from the Easysoft Support team (). Copy the distribution to the same machine that you installed the Salesforce ODBC driver on. Run the distribution to install TDS Server. (You may have to do this from a command prompt that you run as Administrator.) When the installation completes, choose to run License Manager. Use the License Manager program to obtain a trial license for TDS Server.
You now need to configure TDS Server, for example, tell the program which ODBC data source to use.
- On the Windows Start menu, choose Easysoft > TDSS Config.
- In the TDS Config window, in the left-hand pane, select 11433 Sample Listener.
- In the right-hand pane, choose the Edit button.
- Change the TargetDSN field value to the name of the Salesforce ODBC data source that you configured earlier.
- Change the 64Bit field value to Y, and then choose Save. Choose Yes when prompted whether to replace the existing entry and to restart the service.
Create a linked server in SQL Server Management Studio (SSMS) that connects to the TDS Server.
- Start SSMS and connect to the SQL Server instance that you want to access Salesforce from.
- Right-click Server Objects > Linked Servers. Then choose New Linked Server.
The New Linked Server dialog box is displayed.
- In the Linked server box, enter:
TDSS
- In the Data source box, enter:
ip address,11433
Replace
ip address
with the IP address of the machine where you installed TDS Server. - If your Salesforce ODBC data source authenticates with Salesforce by using a user name and password (as illustrated in the example data source shown earlier), choose the Security tab, and then choose Be made using this security context, and then enter your Salesforce user name and password in the spaces provided. If your data source uses OAuth to authenticate, skip this step.
- Choose OK.
- Run a sample query. For example:
select top 10 * from TDSS.SF.DBO.Account