Create, Save and Load a Query in SQL Server Management Studio

Learn how to use the SQL Server to create, load and save database queries.

Important: Before executing any queries on an Advance Steel database, make sure you create backup copies of the databases that will be modified, by adding them in a backup folder in a desired location on the disk.

When editing Advance Steel databases, some actions may be repetitive. You may need to perform identical or similar steps for multiple database tables. When you use SQL Server Management Studio to edit Advance Steel databases, this is achieved by using queries.

A query is an inquiry into the database used to extract or add data, through a set of steps. This scenario of steps can be saved and re-used later for a different database or database table.

To create a new query:

  1. In the Object Explorer, attach the database.
  2. In the Object Explorer, right-click on the database that needs to be edited and select New Query from the contextual menu.
  3. This will open a new tab window on the right side.
  4. In the new window, type the query lines that dictate what changes should be applied to the database.

After entering the query content, the query can be executed right away or saved for later use.

To save a query:

  1. Use the Save command in the application toolbar.
  2. In the Save File As window, choose a name and a location to save your query.

To load a saved query:

  1. In the Object Explorer, select the database that you want to apply the query to.
  2. 2. Use the Open command in the application toolbar.
  3. 3. In the Open File window, navigate to the location of the saved query, select it and click Open.
  4. 4. The query is automatically opened and it can be adapted (if needed) and executed to apply the required changes to the database.