Click here to monitor SSC

Bart

Software Engineer - Red Gate Software

How to use SQL Prompt 3 without being dbo...

Published Wednesday, February 28, 2007 2:36 PM

For anyone out there working with SQL Server on a large or mission critical system it's quite likely that, unless you're the DBA, you're not going to have dbo access to the databases you're working with, particularly if you're working directly with the production servers. Unsurprisingly then we've had a number of complaints from people finding themselves in exactly this situation who want to be able to use SQL Prompt 3, but can't because it generally doesn't work unless you're dbo.

Fortunately my colleague Jon this morning let me know that a solution is at hand for SQL Server 2005 at least, although you're still going to have to be nice to your DBA to make this work (I'd suggest that beer often helps). What you need to do is ask him or her to grant you the VIEW DEFINITION permission on the database of interest. What this means is that you'll be able to see all the meta-data for any object defined in the database, but you won't have access to the objects themselves, so for example you won't be able to read any data from a table unless you have the permissions required to do so.

For example, say your username is "bill" and you need access to the AdventureWorks database, then your DBA would need to execute the following command:


GRANT VIEW DEFINITION ON Database::AdventureWorks TO bill


Now, just to be clear about exactly what access this gives you, here's an extract from SQL Server 2005 books online that explains how this permission works:

"The VIEW DEFINITION permission lets a user see the metadata of the securable on which it is granted. However, VIEW DEFINITION permission does not confer access to the securable itself. For example, a user that is granted only VIEW DEFINITION permission on a table can see metadata related to the table in the sys.objects catalog view. However, without additional permissions, the user cannot read data from the table."

You might still be curious about why SQL Prompt needs this permission, and the reason has to do with the fact that back in the mists of time (last May) we decided to use the SQL Compare back-end to retrieve our meta-data. Now this is a great example of software reuse, and it saved us an awful lot of development time, however when you reuse something for a purpose for which it wasn't originally intended you can't really be surprised if you encounter the odd hiccup along the way.

The problem here is that SQL Compare doesn't trust the SQL Server system tables or views (wisely if you think about what it's supposed to do) so it works out most of what it needs to know by parsing the SQL definitions for the objects in your database, and if it can't get at the definition then it can't build up a model of your database. Now for SQL Prompt having partial information is OK since giving people some help is probably better than giving them no help whatsoever, but if you want to find out what the differences are between two databases then anything less than complete and accurate information really won't do at all, and SQL Compare therefore gets mardy as you like if it can't get the information it needs.

You can be sure that we'll be working on fixing this in the future but in the meantime cultivate kindness towards your DBA and ask them nicely to grant you the VIEW DEFINITION permission on your database and all will be well.
by Bart Read
Filed Under: ,

Comments

 

Bart Read said:

Just as an addendum, I should probably have made it clearer that we're not yet aware of a workaround for this that would work for SQL Server 2000, so for now at least you're stuck with needing dbo access to the database.
March 16, 2007 6:02 AM
You need to sign in to comment on this blog

About Bart Read

Bart has done many things since he started work at Red Gate Software Ltd in August 2004, but nowadays he's (mainly) the product manager for the .NET Developer Tools. He still feels like this is a bit like admitting you were cheering for the Empire whilst watching Star Wars, but for now he's along for the ride. In a previous incarnation he was a project manager leading the .NET Reflector Pro, ANTS Memory Profiler 5, ANTS Performance Profiler 4 & 5, and SQL Prompt 3.0 - 3.6 projects. He still occasionally writes some code and, in the past, has touched the code for most of the Red Gate SQL developer tools... some of them still haven't recovered from the shock. He was born and grew up in Dorset, was educated in Nottingham and London, and likes music and real ale. His photo is extremely misleading.
Latest articles
Backups, What Are They Good For?
 We've heard the confessional story from Pixar that Toy Story 2 was almost lost due to a bad backup, but... Read more...

C# Async: What is it, and how does it work?
 The biggest new feature in C#5 is Async, and its associated Await (contextual) keyword. Anybody who is... Read more...

Handling Deadlocks in SQL Server
 In this excerpt from his book Troubleshooting SQL Server: A Guide for the Accidental DBA, Jonathan... Read more...

SQL VIEW Basics
 SQL Views are essential for the database developer. However, it is common to see them misued, or... Read more...

The PoSh DBA: Grown-Up PowerShell Functions
 Laerte goes step-by-step through the process of tidying up and making more reusable an untidy... Read more...