In this article, the feature that tracks SQL queries whether they be executed or unsaved, and saves them in the appropriate folders/files for later use in ApexSQL Complete will be described.
ApexSQL Complete is add-in for SSMS and Visual Studio that speeds up coding and improve productivity using features such as SQL snippets, auto-replacements, auto inserting statements and more.
Track ran queries
To keep track of executed queries in SSMS and Visual Studio, check whether the Log ran queries option, under the Query history tab is enabled. By default, this option is checked:
From now on, all the queries that are executed in SSMS or Visual Studio will be saved into the ExecutedQueries.xml file. By default, this file is located under the following path:
The information about executed queries is managed in such a way that a separate folder is created based on the date (e.g. 03-23-2016, 02-24-2016) and each folder contains an ExecutedQueries.xml file in which is stored information about executed queries for that date.
The ExecutedQueries.xml file contains information about the user who executed a query, the date and time of the execution, duration of the execution, status of the query (whether committed successfully or with an error), from which database was the query executed and query code that is executed:
To view executed queries, go to the ApexSQL Complete menu and from the drop-down list click the Query history command:
This will open the Query history window:
On startup, the Query history window, will show the list of all executed queries for the particular set of date that is set in the Default period option under the Query history tab:
Additionally, a number of executed queries that will be displayed in the list can be changed by changing the date in the From and the To combo boxes:
Reusing executed queries
Content of executed queries can be copied from the details pane, or double-click on the desired query from the list, it will automatically put the query content in a new query window:
Track unsaved queries
In a situation when an accidentally closed unsaved query, causes a potential loss of work, the Tab navigation option in ApexSQL Complete add-in can be very useful.
In order to use the Tab navigation option to start tracking any opened or closed tabs, the Enable tab navigation option must be enabled. From the Options window in the Tab navigation tab, select the Enable tab navigation option:
By default, the Enable tab navigation option under the Tab navigation tab is disabled
To use this option, the Tab navigation pane must be initiated. From ApexSQL Complete menu, click the Tab navigation command:
Which will show all opened tabs in the Open section:
Closed tabs, no matter whether are saved or not, will be saved in the Closed section:
By default, each of the opened and recently closed tabs are saved as an XML file here:
XML files are placed in the appropriate folder, which title contains the version of SSMS/VS where XML files are created (e.g. SQL Server Management Studio 2014, Microsoft Visual Studio 2013)
Reusing unsaved queries
The content of unsaved queries can be copied from the details pane and, also by double-clicking on the query from the list in the Closed tab. The latter will open the query content in a new query window and remove the clicked query from the Closed tab list and move to the Open tab list:
The content of the Tab navigation and the Executed queries folder can be copied and moved to another machine where ApexSQL Complete is installed.
March 31, 2016