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:
- In the Object Explorer,
attach the database.
- In the Object Explorer, right-click on the database that needs to be edited and select New Query from the contextual menu.
- This will open a new tab window on the right side.
- 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 execute a query, use the Execute command in the application toolbar. After the process is finished a confirmation message will be displayed at the bottom of the query window, stating that the query was executed successfully. The changes are automatically applied to the database and it can be used accordingly.
- To re-use the query in the future, save it. When needed, just open the saved query and adapt it as required.
To save a query:
- Use the Save command in the application toolbar.
- In the Save File As window, choose a name and a location to save your query.
To load a saved query:
- In the Object Explorer, select the database that you want to apply the query to.
- 2. Use the Open command in the application toolbar.
- 3. In the Open File window, navigate to the location of the saved query, select it and click Open.
- 4. The query is automatically opened and it can be adapted (if needed) and executed to apply the required changes to the database.