Coupon code copied
Server Intellect
(855) 850-HOST

Toll Free 24/7/365        (4678)

Get help from a Microsoft Certified Engineer.

Intellect Connect

Technical problem with your Windows Hosting?

Let our Microsoft Certified experts handle the problem for you.

How to Run a SQL Query

In a Structured Query Language (SQL) database, commands are executed via the use of queries, which are specific instruction sets run against the database for performing a multitude of tasks, such as formatting tables, removing or adding data, and executing stored procedures.

Although creating a custom SQL query requires programming skill and a thorough knowledge of the Structured Query Language, running a query through SQL Server Management Studio is easily accomplished.

Step 1

First, you will want to log into SQL Server Management Studio either locally on your server, or via remote connection. For the purposes of this article, we will use an example where the user is logging in locally using Windows Authentication.

kb-sql-query-1

Step 2

Next, you will want to select from the list of databases the one which you are running the query against. In this example, we will be running it against the ‘master’ database.

(Please note that this is only an example used for the purposes of this article, and the ‘master’ database should be edited with extreme caution, as it is inexorably tied to all other databases hosted on the server, and contains several vital stored procedures.)

Once the database is selected, click on the button in the upper left-hand corner of the window which says, ‘New Query‘.

kb-sql-query-2

Step 3

A window will then open beside the database list, enabling you to enter your query. Once it has been entered, click the button which says ‘Execute‘ at the top of the window. Management Studio will then run your query against the selected database, and once processed, it will confirm whether or not the query was run successfully.

kb-sql-query-3

Having Problems with Windows Server?

Try our troubleshooting service

  • Microsoft Certified Engineers
  • Remote Log-in to Your Servers
  • End-to-End Troubleshooting

Our Certified Technicians have been supporting Microsoft® products for well over a decade.

Tell us where you are getting stuck

Get Help Now!

Having Trouble Solving This Problem?

Let our Microsoft® Certified Engineers fix it for you.
Just $50.00 one time fee.

Having Trouble Implementing This Solution?

Why not let our Microsoft® Certified Engineers do it for you.
Just $50.00 one time fee.

Request Immediate Expert Help

Step 4

Some queries will be pre-compiled in a file with a ‘.sql’ extension. These are easily run, as well. Essentially, once the window in the above picture is open, double-click the ‘.sql‘ file, and it will automatically open within Management Studio. Once opened, click ‘Execute‘.

Please bear in mind that it is always good practice to back up a database prior to running any type of query against it. For assistance with backing up a database, please see the following Knowledge Base article:

How to Backup a database using Management Studio

Interested in letting our experts solve your IT problems for you?
Get a free, no-obligations consultation with one of our experts today!

Call us at (855) 850-HOST

Contact

Start Your Order

X

This form does not accept free e-mail accounts. Please enter a business e-mail to submit it.

Submit Form Cancel

Please wait...

Submitting your info. This may take less than a minute.