to watch a video on this subject
Named query is a convenient way of executing a SQL query even if you are not connected to a database. Additionally, you can embed a named query within another SQL statement.
Prerequisites for using Named Queries
- You must be using WinSQL Professional
- Version must be 9.0 or higher
- Only one query can be used. If more than one query is found, WinSQL will select just the first one.
- It is recommended you only use SELECT statements in a named query. Running a named query is very easy and creating a Named Query for a DML statement can unintentionally modify data on the back-end.
Creating a new Named Query
Following steps demonstrate how to create a Name Query
- Connect to your desired database
- Either write a new SQL statement manually, or open an existing script
- Highlight the desired query within the script.
- Either select Save Named Query under the File menu, or select it from the pop-up menu by clicking the right mouse button. Following window appears
- Assign a name and click Ok
- The newly saved named query appears on the right hand side of the screen.
Benefits of using Named Queries
Named queries store connection information besides the SQL for queries. Therefore, if you need access to the results of a query very fast, consider saving that query as a Named Query.
Following statements apply to Named Queries.
- Double clicking any existing Named Query opens the script in a new MDI window. It automatically establishes connection to the back-end database.
- Double clicking does not execute the query. It just opens it up in a new window
- Click the right mouse button on an existing Named Query and select Run Query to Clipboard to execute the query and copy data to the clipboard. Data on the clipboard is tab delimited.
- Named Queries can be used in Cross Database Queries.