SQL Prompt 10

Searching SQL History

The entire history of all of your queries can be searched using SQL History. To find a query, type some text and the results will be shown in the list below.

All words in the search text will have to be matched for a query to be classed as a result.

Wildcards are supported in the search text:

WildcardDescriptionExample
*matches 0 or more charactersproc* will match both proc and procedure
?matches exactly 1 of any characteran? will match both and and any


Searches can also be limited to different properties of a query by using one of several prefixes:

PrefixDescriptionExample
nameSearch only in the name of queriesname:fix
pathSearch only in the file path of queriespath:useful
sqlSearch only in the contents (SQL) of queriessql:alter

Advanced search

For more control over the filtering of results, you can use the advanced search section.


This allows filtering based on the different properties of a query/version. The filters can also be defined as prefixes in the search text.

FilterDescriptionPrefixExample
Object typeSearch everything, just queries, or just query versions.typetype:query, type:version
Search periodLimit how far back the search extends.datedate:[yyyyMMddHHmm TO yyyyMMddHHmm]
ServerLimit the results to queries connected to a particular server.serverserver:production.database.windows.net
DatabaseLimit the results to queries connected to a particular database.databasedatabase:AdventureWorks
State - StarredLimit the results to queries that have been starred or not.starredstarred:true, starred:false
State - OpenLimit the results to queries that are currently open/not open.openopen:true, open:false


These can be combined together to find very specific things in the SQL history:

type:query date:[202212010000 TO *] database:Adventureworks open:false starred:true

Additional search features

To search for a series of words that appear together in a query, put the words in double quotes (e.g. "create view").

By default, all words in the search text will have to be matched for a query to be classed as a result. This can be changed by using OR between the words (e.g. select OR alter).

Specific words can be excluded from results by using the NOT operator (e.g. alter NOT table).

Both the OR and NOT operators must be in upper case for them to be recognized as an operator.

Why am I not getting the results I expect?

Casing of both the words you are searching with and the query text you are searching for can have an effect on the results. To give the likeliest optimal results, compound words are broken up when searching. To do this, capital letters are treated as a word boundary.

For example, if the table CustomerOrders appears in a query, this will be broken into Customer, Orders and CustomerOrders when searching. Searching for any of these will get a result. If the CustomerOrders table was defined as Customerorders instead, searching for customer or orders will not find it.

The same word boundary logic is applied for the text being used in the search.

If you don't find what you expect to, try to change the search text slightly by lower casing it and splitting words apart.



Didn't find what you were looking for?