ImportSqlQuery Script Examples

From QPR ProcessAnalyzer Wiki
Revision as of 08:11, 20 June 2016 by TeeHiet (talk | contribs) (403051)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page contains script examples for the ImportSqlQuery script command.

The following example will load data from an ADO.NET source (a sample database called DB1 on Microsoft SQL Server) and select all columns from the table EXAMPLE. It will then put that data into the "#TABLE" temporary table, and then show the contents of that table.

(SELECT 'SqlConnectionString', 'Data Source=(local);Initial Catalog=DB1;Integrated Security=true') UNION ALL
(SELECT 'SqlQueryString', 'SELECT * FROM EXAMPLE') UNION ALL
(SELECT 'TargetTable', '#TABLE') UNION ALL
(SELECT 'Append', '1')
--#ImportSqlQuery

(SELECT * FROM #TABLE) 
(SELECT 'MaximumCount', '0') 
--#ShowReport 

The following example will load all the columns from "EXAMPLE" table in SQL Server database and will put that data into the "ExampleDataTable" in the "ExampleProject" project. It will then get the Data Table analysis from the "ExampleDataTable", put that into the "#TABLE" temporary table and then show the contents of that table.

(SELECT 'ProjectName', 'ExampleProject') UNION ALL 
(SELECT 'DataTableName', 'ExampleDataTable') UNION ALL 
(SELECT 'Append', '0') UNION ALL 
(SELECT 'SqlConnectionString', 'Data Source=(local);Initial Catalog=DB1;Integrated Security=true') UNION ALL 
(SELECT 'SqlQueryString', 'SELECT * FROM EXAMPLE')
--#ImportSqlQuery

(SELECT 'AnalysisType', '18') UNION ALL 
(SELECT 'ProjectName', 'ExampleProject') UNION ALL 
(SELECT 'MaximumCount', '0') UNION ALL 
(SELECT 'DataTableName', 'ExampleDataTable') UNION ALL 
(SELECT 'TargetTable', '#TABLE') 
--#GetAnalysis 

(SELECT * FROM #TABLE) 
(SELECT 'MaximumCount', '0') 
--#ShowReport