Using ODBC Driver in SQL Server 2008 and 2012
Use the ServiceNow ODBC driver in SQL Server as a Linked Server. This allows SQL Server to query tables from a ServiceNow instance directly via the ODBC Driver. Only use the procedures described with SQL Server 2008 and 2012. Other versions of SQL Server may cause unexpected behavior.
2 Configuring SQL Server
The following example configuration was performed on SQL Server 2008, installed on Windows Server 2008.
- Run the SQL Server Management Studio as Administrator and log in to the database to which you want to link.
- Right-click on Server Objects > Linked Servers.
- ClickNew Linked Server.
- Enter the following values in the dialog.
- Linked server: SERVICENOW. This is the name of the Linked Server.
- Provider: Microsoft OLE DB Provider for ODBC Drivers
- Product name: ServiceNow. This is an identifier. Enter any value that is appropriate.
- Data source: ServiceNow. This is the name of your DSN.
- Select Security from the Select a page list, and then enter the following security values:
- Navigate to Server Objects > Linked Server > Providers and double-click Microsoft OLE DB Provider for ODBC Drivers.
- Select the following options.
- Nested Queries
- Level zero only
- Support 'Like' operator
- Tip: ServiceNow recommends running the third-party provider in the out-of-process mode setting (AllowInProcess=FALSE). If you run the provider in-process (within the same process as SQL Server), then any issues with the provider can affect the SQL Server process, which in turn could result in crashing SQL server.
- Test your connection by selecting the newly created linked server SERVICENOW and selecting Test connection.
- Execute the following query in a query builder window to retrieve some results.
Additional information on how to resolve permission related issues for SQL Server Linked Servers can be found at this URL http://blogs.msdn.com/b/dataaccesstechnologies/archive/2010/08/19/permissions-needed-to-set-up-linked-server-with-out-of-process-provider.aspx
2.1 Number Precision Errors
You may encounter precision errors querying for decimal or number field values using the OPENQUERY syntax with the ODBC driver. In this case, use the Cast syntax to convert the precision. For example:
SELECT * FROM OPENQUERY(SERVICENOW, 'select Cast(sys_mod_count as Decimal(38,0)), number, short_description from incident') GO
2.2 SQL Server Connection String
To use the ODBC driver directly in SQL Server 2005 or SQL Server 2008, specify the connection string in the following format.
|Note: The latest SQL Server 2008 patches are required for the ability to specify a connection string in the user interface, via the SQL import wizard|
The following example creates a linked server named "ServiceNow ODBC" that uses the Microsoft OLE DB Provider for ODBC (MSDASQL) and the data_source parameter
EXEC sp_addlinkedserver @server = N'ServiceNow ODBC', @srvproduct = N'', @provider = N'MSDASQL', @datasrc = N'ServiceNow'; GO
After creating the Linked Server , you must update its properties to specify the user name / password login credentials.