Tag Archive: ssms

Fixing SQL Server Management Studio’s Tab Text

I hate the way SSMS tabs look by default.  Check this out:

SSMS Tab Defaults

SSMS Tab Defaults

That’s nearly useless.  The tabs are wide, but they still don’t show useful information.  Even worse, I’ve got more tabs than I can fit in the window, so the rest hang out in a meaningless dropdown.

To fix it, click Tools, Options,and go into Text Editor, Editor Tab and Status Bar.  Check out the Tab Text options:

Tools, Options

Tools, Options

You can uncheck the database name, login name, and server name because those are shown in the status bar anyway.  Then, if you wanna get fancy, change the status bar location to Top – it’s right above the Tab Text options.  Voila:

SSMS Tabs Fixed

SSMS Tabs Fixed

When I’m working, I save my queries in c:\temp with a short descriptive name.  If I’m performance tuning, I’ll save them as Before.sql and After.sql, or maybe Index1.sql and Index2.sql.  Presto, I can easily switch tabs without playing the guessing game.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

Playing Around with SQL Azure and SSMS

The latest build of SQL Server Management Studio for SQL 2008 R2 includes built-in support for SQL Azure.  The November CTP is still only a feature-complete preview, not a release candidate, so don’t go installing it willy-nilly on your production desktop.

To use this, you’ll need a SQL Azure account.  You can register for an invitation code, and while you’re waiting, check out the SQL Azure Team Blog and the Microsoft SQL Azure site.

Create an Azure database and get the connection string.

Go to sql.azure.com and sign in with your Live account.  By default, your database list will just show master:

Azure Database List

Azure Database List

Click the Create Database button at the bottom and enter a new database name.  You can either pick 1GB max size or 10GB, and when Azure goes live, you’ll either be billed $10 per month or $100 per month.  Your database list will refresh.  Click on the new database name, and click the Connection String button to get the full string.  All you really need is the server name.

Azure Connection Strings

Azure Connection Strings

Open the SQL Azure Firewall

Just like SQL Server 2008 ships with remote connections disabled, so does Azure.  To open ‘er up, click the Firewall Settings tab in the SQL Azure web control panel and click Add Rule.

Adding a SQL Azure Firewall Rule

Adding a SQL Azure Firewall Rule

Enter a name and an IP address range and submit.  SUBMIT, I TELL YOU!  (Guys, seriously, it’s 2009.  Stop using S&M verbiage on your web forms.)

Open SQL Server Management Studio and Connect to SQL Azure

Open SSMS and start a new Database Engine connection.  Copy/paste the server name from the connection string you generated earlier.  Use SQL Authentication (not Windows trusted authentication) and enter the username and password you set up for SQL Azure.  (This is not your Microsoft Live account.)  Click Connect, and you get a normal Object Explorer browser:

SQL Azure in SSMS

SQL Azure in SSMS

Click View, Object Explorer Details, and you can see the compatibility level, recovery model, and collations – in my case, 100, full, and case-insensitive:

Object Explorer Details

Object Explorer Details

If your firewall settings haven’t taken effect yet, or if you didn’t set up a rule for your current IP address, you’ll get an error like, “Cannot connect to gr8clozgxt.database.windows.net.  Cannot open server ‘gr8clozgxt’ requested by the login. Client with IP address ’85.18.245.70′ is not allowed to access the server. Log in failed for user ‘brento’. (Microsoft SQL Server, Error: 40615).”

Azure Connection Fail

Azure Connection Fail

Go back into the SQL Azure control panel and double-check your firewall rules.

Poking Around in SQL Azure

Now the fun starts.  First off, you can’t right-click on the server itself.  You can right-click on a user database, but there’s no Properties or Tasks.  If you right-click in the Tables list and click New Table, you don’t get a GUI – you get a table creation script.  Put the mouse away, speedy, because you’ve got some scripting to do.  Speaking of scripting, there’s a new option in SSMS for the type of database engine you’d like to script for, either “Standalone SQL Server” or “SQL Azure Database.”

Scripting Options

Scripting Options

You’ll find the master database in the System Databases tree, but no model or tempdb database.  There are no system tables visible in either your master database or your user databases, but there ARE system views like INFORMATION_SCHEMA.

Cross-database querying is a little odd.  In Object Explorer, click on the master database and click New Query.  The database dropdown is simply grayed out, and you can’t change databases once a connection has started.  Try to change it with a USE statement, and you get the following error:

Msg 40508, Level 16, State 1, Line 1
USE statement is not supported to switch between databases. Use a new connection to connect to a different Database.

You can’t specify the master database name, either.  You can query master system views like sys.bandwidth_usage, sys.database_usage, sys.firewall_rules, and sys.sql_logins only from the master database.

Querying sys.firewall_rules

Querying sys.firewall_rules

If you try fully qualifying their names like this:

SELECT * FROM master.sys.firewall_rules

You get an error:

Msg 40515, Level 16, State 1, Line 1
Reference to database and/or server name in 'master.sys.firewall_rules' is not supported in this version of SQL Server.

Or this one:

Msg 10054, Level 20, State 0, Line 0
A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

Innnteresting.  Not everything’s quite hooked up in the Object Explorer either – try drilling into the Replication Options, and you’re told that “Operation not supported on version 10.25. (Microsoft.SqlServer.SqlEnum)”.

Not So Fast

Not So Fast

All in all, it’s an exciting step.  So let’s poke around the way a production DBA would:

Things That Don’t Work in Azure

Try this:

EXEC dbo.sp_who

And you get this:

Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'dbo.sp_who'.

And same with our old buddy sp_configure – he’s not found either.

Try this (I picked spid 157 because that was my current logged-on one, and I found that high number rather interesting, but that’s a story for another post):

DBCC INPUTBUFFER(157)

And you get this:

Msg 40518, Level 16, State 1, Line 1
DBCC command 'INPUTBUFFER' is not supported in this version of SQL Server.

Same thing with CHECKDB.  All my good friends in the DMVs are MIA, too.

Which brings me to the final thing that doesn’t work in Azure – the production DBA.  In short, anything a production DBA would rely on isn’t there – and that’s because in theory, at least, Azure doesn’t need production DBAs.  Azure’s $100/mo 10GB pricing only seems expensive until you compare it to the cost of a full-time DBA for a small business.  I, for one, welcome our new Azure overlords, but only if they knock performance, availability, and scalability out of the park.

Is there anything you would like to see tested and documented about SQL Azure?  Let me know and I’ll take my best shot.  I plan on running some ballpark performance numbers over the coming weeks for starters.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

My Weekly Bookmarks for October 30th

Here’s my bookmarked links for October 26th through October 30th:

SQL Server Links

#SQLPASS Links

Tech Links

The Junk Drawer

These bookmarks are automatically imported from my bookmarks at Delicious.com. If you’d like to get up-to-the-minute updates on what I’m bookmarking, you can subscribe to my bookmark RSS feed.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

My Weekly Bookmarks for October 2nd

Here’s my bookmarked links for September 25th through October 2nd:

SQL Server, Cloud, and Tech Links

Writing, Blogging and Networking Links

The Junk Drawer

These bookmarks are automatically imported from my bookmarks at Delicious.com. If you’d like to get up-to-the-minute updates on what I’m bookmarking, you can subscribe to my bookmark RSS feed.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

My Weekly Bookmarks for September 14th

Good news and bad news – the good news is that everybody’s been going wild and crazy for the SQLServerPedia PASS contest.  The bad news is that editing the articles & setting up the bloggers has eaten up every moment of my spare time, hahaha.  As a result, I had to do the unthinkable this weekend: scan through Google Reader and then hit mark-all-as-read.  Here were the survivors, and I’m sure I missed some good stuff:

These bookmarks are automatically imported from my bookmarks at Delicious.com. If you’d like to get up-to-the-minute updates on what I’m bookmarking, you can subscribe to my bookmark RSS feed.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts

SQL Server 2008 Management Studio: Group Execute

I’m going to show how to use a new feature in SQL Server 2008 Management Studio: the ability to query groups of servers simultaneously.

In Registered Servers, right-click on a group of servers and click New Query. What comes up will look like a normal query window, but pay close attention to the very bottom of the screen after we run a query:

SQL Server 2008 Management Studio Group Execute

“Group L” shows the name of my registered server group. I keep my lab servers in Group L for Lab.

“LAB\Administrator” is the login that was used for authentication. (Okay, you caught me, I’m logging in as the domain admin. Thank goodness this isn’t a blog post about security.)

“Master” is the database, of course, and it would make sense to use Master because it’s one of the few databases we know exist on every server.

“6 rows” is obviously the number of rows the query returned, but let’s take a look at the query and the number of rows:

SSMS 2008 Querying Multiple Servers At Once

I ran a “SELECT GETDATE()” against this group of servers, and SQL Server Management Studio did the hard work for me: it connected to every SQL Server in the group, ran that query, and then combined the results back into a single results grid. It automatically added a “Server Name” column at the beginning of my results to identify which server (and which instance) the results came from. If we ran a query that returned multiple rows per server, that would work fine too.

This query would be useful if we wanted to check the dates on all of our servers, but let’s be honest – that’s not a big problem for us database administrators. We’re geniuses.

Taking a SQL Server Inventory with SSMS 2008

Let’s go tackle a harder problem, like taking an inventory:

Getting Multiple SQL Server Versions

Run SP_Configure on Multiple Servers

In the above example, I’ve grabbed the SQL Server version for each of my instances. Now we’re starting to get somewhere, but what we really want is the kind of detailed information we can get from sp_configure, so let’s see how that looks:

Now we’re cookin’ with gas – but wait. Look at that first column. We’re getting lots of data back, multiple rows for each server, and it’s hard to compare this data back and forth. For example, maybe I want to see whether “allow updates” is turned on for all of my servers – so I should probably sort by “name”, right?

Can’t Really Order By with SSMS 2008 Group Execute

Uh oh – turns out that doesn’t work. Remember, SQL Server Management Studio simply runs this same query on every single instance, then dumps the data into the SSMS results window. It doesn’t process the query results together. You can’t “join” between tables on different servers – well, you can, but you have to set up linked servers, and that doesn’t really have anything to do with the Group Execute functionality.

Another thing you’ll want to do is take this data and insert it into a table. Again, no dice there – if you try to insert this into a temp table like this:

SELECT @@SERVERNAME INTO #MyServerList

SSMS will execute that query on every single server, so every server will end up with its own temporary table with one record in it. Not exactly what you wanted.

Next up on our feature list: the ability to schedule these multi-server queries and take action on the results. I might want to run a query every night checking for failed jobs or sp_configure changes. Again, not going to happen – this can’t be automated with a SQL Server Agent job. This functionality only lives in SQL Server Management Studio.

Be Aware of Case Sensitive Collations

One more thing you want to be aware of: if any of your servers are case-sensitive, then you need to write all of your group execute queries in the proper case. I recommend that if you’ve got any case-sensitive instances, then use a case-sensitive instance as your personal testbed server like on your workstation. That way, as you’re writing new utility queries, you’ll know for sure that they’ll succeed on your case-sensitive instances. It’s a real pain to bang out a hundred-line utility query only to find out you’ve got case errors all over the place when you try to execute it.

It might sound like I’m down on this feature, but I’m not: it’s really useful. I love using it to quickly find out a piece of information across lots of servers, like find out if there’s any locking or deadlocks going on. It’s also really useful if you’ve implemented a Central Management Server as a centralized list of your instances. But it’s not a solution for automated reporting or proactive reporting.

Worry not – SQL Server 2008 has a different new feature specifically aimed at automated, proactive management: Policy-Based Management.  More on that later.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

Website - Twitter - Facebook - More Posts