Home
Loading data from Microsoft SQL Server
When accessing data from a Microsoft SQL Server database, nextanalytics (on a Windows platform) can leverage the built-in ADO.NET drivers and access the database direct without the need for an ODBC connection. Two pieces of information are required: a SQL query, and a connection string to the data source.

With nextanalytics, the SQL query can be referenced from a file, or included within the script. Referencing a file allows the SQL query to be developed and tested independantly, then simply referenced by the script, while including the query in the script makes the data source explicit and allows for ad-hoc changes. In all cases, the query field names should be preceeded with one of the column role identifiers 'rowlabel_', 'text_', 'numeric_' or 'ignore_' (more about column roles).

A valid connection string is also required (reference MSDN or connectionstrings.com for assistance).

For example, a SQL query can be stored in a file in the nextanalytics 'Pages' directory as defined in your variables.config file:

ProductSafetyStock.sql
  1. SELECT name as rowlabel_name, productnumber as text_productnumber, safetystocklevel as numeric_stock from adventureworks.production.product

 

Then the nextanalytics script can reference the query file, and using the defined connection string, run the query and save the results to a nextanalytics optimized 'nod' file (located in the nextanalytics 'Data' directory as defined in the variables.config file).

nextanalytics script
  1. Query , Command , ProductSafetyStock.sql
  2. Query , RunSave , SQL , "Data Source=dbserver;Initial Catalog=AdventureWorks;user id=testuser;password=Pass@word1;trusted_connection=no" , sqlquery.nod

 

Performing the same query without a seperate query file would look like this:

nextanalytics script
  1. Query , Command , "SELECT name as rowlabel_name, productnumber as text_productnumber, safetystocklevel as numeric_stock from adventureworks.production.product"
  2. Query , RunSave , SQL , "Data Source=dbserver;Initial Catalog=AdventureWorks;user id=testuser;password=Pass@word1;trusted_connection=no" , sqlquery.nod

 

 
< Prev   Next >