Use the SugarCRM ODBC driver to connect Microsoft SQL Server to SugarCRM and:
Note If you want to use the linked server in a clustered environment, you need to install the ODBC driver on each node in the cluster.
For installation instructions, refer to the SugarCRM ODBC driver documentation.
Before you can use the SugarCRM ODBC driver to connect SQL Server to SugarCRM, you need to configure an ODBC data source. An ODBC data source stores the connection details for the target database (in this case, SugarCRM) and the ODBC driver that is required to connect to it (in this case, the SugarCRM ODBC driver).
Note If you want to use the linked server in a clustered environment, you need to configure the data source on each node in the cluster.
You can configure a user ODBC data source, which is only available to the user who creates it, or a system ODBC data source, which is available to all users on the machine. You configure ODBC data sources in ODBC Data Source Administrator, which is included with Windows. Note that a user data source is only available to a SQL Server instance if that instance is run as a specific user, otherwise, you must use a system data source.
There are two versions of ODBC Data Source Administrator. The version of ODBC Data Source Administrator that you need to run depends on whether you have a 32-bit or a 64-bit version of SQL Server. To find out which version of SQL Server you have, connect to your SQL Server instance, and then run this SQL statement:
SELECT SERVERPROPERTY('edition')
If you have the 64-bit version of SQL Server and want to use a linked server with the SugarCRM ODBC driver, you need to run 64-bit version of ODBC Data Source Administrator. To do this, open Administrative Tools in Control Panel, and then open Data Sources (ODBC). (On Windows Server 2003 and earlier, the Control Panel applet that launches ODBC Data Source Administrator is labelled Data Sources. On Windows 8 and later, the Control Panel applet is labelled ODBC Data Sources (64-bit).)
If you have the 32-bit version of SQL Server or want to use SSIS with the SugarCRM ODBC driver, you need to run the 32-bit version of ODBC Data Source Administrator. To do this, in the Windows Run dialog box, enter:
%windir%\syswow64\odbcad32.exe
Use ODBC Data Source Administrator to create your SugarCRM ODBC driver data source:
Important This will only succeed if the SQL Server instance is running under the same user account as the one used to create the data source. Otherwise, you must create a System ODBC data source instead.
–Or–
Setting | Value |
---|---|
DSN/td> | SugarCRM |
User Name | The name of your SugarCRM user. For example, admin . |
Password | The password for your SugarCRM user. |
Logon Uri |
The URI of the SugarCRM instance that you want to connect to. For example:
https://sg-richarddemo.demo.sugarcrm.eu/ The SugarCRM ODBC driver can connect to a SugarCRM instance over both |
You can now connect SQL Server to SugarCRM.
You need to log on with an account that is a member of the SQL Server sysadmin
fixed server role to create a linked server.
SugarCRM
.SQL Server verifies the linked server by testing the connection.
PATH
environment variable. The SugarCRM ODBC driver Setup program adds entries for the driver to the System PATH
. Restarting the instance makes these changes available to SQL Server, allowing it to load the SugarCRM ODBC driver.A four-part table name has the format:
server_name.[database_name].[schema_name].table_name.
Even though with SugarCRM there is no database or schema, the Easysoft ODBC-SugarCRM Driver returns a "dummy" value for both identifiers, because some ODBC applications expect there to be a database and a schema. The database that the driver returns is SUGAR
. The schema that the driver returns is DBO
. Include thse identifiers in your SQL statements. For example:
SELECT * FROM SUGARCRM.SF.DBO.Accounts
The capitalisation of the table name must be the same as it is in SugarCRM. For example, the following query is invalid:
SELECT * FROM SUGARCRM.SF.DBO.ACCOUNTS
To check the capitalisation of the SugarCRM tables (objects), run:
EXEC sp_tables_ex @table_server = 'SUGARCRM'
OPENQUERY
function. For example:
SELECT * FROM OPENQUERY(SUGARCRM, 'SELECT * FROM ACCOUNTS')
SQL Server sends pass-through queries as uninterpreted query strings to the SugarCRM ODBC driver. This means that SQL Server does not apply any kind of logic to the query or try to estimate what that query will do.
OPENDATASOURCE
and OPENROWSET
The OPENDATASOURCE
and OPENROWSET
functions enable you to work with SugarCRM data in SQL Server without configuring a linked server. There are some security implications associated with their use and these functions are therefore not enabled by default.
OPENDATASOURCE
and OPENROWSET
functions:
EXEC sp_configure 'show advanced options', 1 RECONFIGURE GO EXEC sp_configure 'ad hoc distributed queries', 1 RECONFIGURE GO
SELECT * FROM OPENDATASOURCE('MSDASQL', 'DSN=MY_SUGARCRM_ODBC_DATA_SOURCE;') .SF.DBO.Accounts
—Or—
SELECT * FROM OPENROWSET('MSDASQL', 'DSN=MY_SUGARCRM_ODBC_DATA_SOURCE;', 'select * from Accounts;')
This command creates a copy of the Account
table, it assumes the linked server is named SUGARCRM
.
IF Object_id('dbo.Account', 'U') IS NOT NULL
DROP TABLE dbo.accounts;
SELECT *
INTO accounts
FROM Openquery(sugarcrm, 'SELECT * FROM Accounts')
These instructions assume that you have Microsoft Visual Studio and SQL Server Data Tools for Visual Studio installed.
.csv
file named categories.csv
with the following contents:
name,is_external "Test Category 1",1 "Test Category 2",0
Flat File Source is under the Other Sources list.
"
.ODBC Destination is in the Other Destinations list.
Product2
.Your Input and Destination columns should look like this:
Input column | Destination column |
---|---|
[is_external] |
is_external |
name |
name |
All other column names will have their input set to <ignore>
.csv
file into SugarCRM.