You Want Me to Put That Where???

In my previous article I mentioned my surprise that many readers were not running the sample code posted on my blog. When I asked a few as to why, the number one answer was that some M2M Admins don’t know which program(s) they can use to query their SQL databases. I don’t know why this came as a shock since M2M Support instructed me how to open Query Analyzer my first time a decade ago. We all start somewhere.

Anyway, I’ve put together this basic tutorial as to how to do that. I’m hitting only the bare basics of how to use the query tools, and will mostly leave it up to you dear reader to Google more about them or to ask questions in the comments.

Keep in mind that you should not remote desktop your server and log into administration and query software on it because that eats up memory and other resources. You should install the SQL tools on a workstation and administer and query remotely. Also, you should never run code from my site, or any site for that matter, on your production server, you really need a test server.

SQL 2000 Query Analyzer

In order to open up the SQL 2000 Query Analyzer, you’ll typically select Start, All Programs, Microsoft SQL Server, and Query Analyzer.

M2M requires you to install SQL Server in Mixed Mode and requires administrator access to its databases. Therefore, you can log in to QA with Windows Authentication or SQL Server Authentication. Notice how the SQL Server selection defaults to “localhost” which is the SQL Engine running on the local machine. You can also substitute that with a “.” as well. When connecting to another server, you can either type the name in directly or select the ellipses and a list of SQL Servers on your network will display for you to select.

After logging into QA, you’ll see a screen similar to the following. I’ve entered a simple query and executed it against M2M’s sample database.

Keep in mind that I’m only covering the basics. Queries are entered in the Query Pane, the results are shown in the Results Pane, and you can browse objects such as databases and fields in the Object Browser. I’ve also highlighted where you can change the database your query will run against, as well as the buttons to check your syntax and execute your query.

You can also execute your query by hitting F5 as well. If you have multiple queries in the window, all will execute. However, selecting and highlighting specific query(ies) and hitting F5 will limit execution to those queries.

SQL Server Management Studio (SSMS) 2005 through 2008/R2

I’m covering all of these together, because for the most part they function the same way. To open SSMS, typically you’ll select Start, All Programs, Microsoft SQL Server 2005 (or whichever version you are using), and SQL Server Management Studio. In the screenshot below, you’ll notice that I’ve substituted a “.” for local host.

After logging in, you’ll see something similar to the following.

Notice that I have browsed into the M2MData01 Database, and you can see the objects in the Summary Pane. To write a new query, select the button I’ve highlighted and the Summary Pane. I’ve written and executed the same query below.

This isn’t to say that there haven’t been improvements in SSMS over the years. Brad McGehee (Blog/Twitter) wrote an excellent article on these improvements some time ago.

Third Party Products

There are several third party products you can use to query your database and I will cover TOAD for SQL Server in a later blog post.

Any questions?

4 comments to You Want Me to Put That Where???

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>