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. The search text is case insensitive.

Wildcards are supported in the search text:

*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:

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.

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

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.

Didn't find what you were looking for?