30.06.2013 Views

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SQL Server Team-based Development - Red Gate Software

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8: Exploring your Database<br />

Schema<br />

Pretty quickly, if you are doing any serious database development, you will want to know<br />

more about a database than SSMS can tell you; there are just more things you might need<br />

to know than any one GUI can provide efficiently. There are a number of reasons why you<br />

might want to search through your object metadata and data definition language (DDL).<br />

For example, if you are doing a review of a development database, there are a number of<br />

facts you'll need to establish regarding the database, its tables, keys and indexes, in order<br />

to home in on any possible problem areas. Likewise, if you are refactoring or maintaining<br />

an existing database that was written by someone else, then you will quickly find that<br />

searching through the schema, click by click, using the SSMS Object Explorer, is not really<br />

a viable option.<br />

For high-speed searching of your schemas, you need a dedicated tool, or a set of your own<br />

search scripts, or probably both. Fortunately, <strong>SQL</strong> <strong>Server</strong> provides any number of ways to<br />

get at the metadata you need. The INFORMATION_SCHEMA views provide basic metadata<br />

about the objects in each database. The far more expansive catalog views offer just about<br />

every piece of object metadata that <strong>SQL</strong> <strong>Server</strong> currently exposes to the user.<br />

This chapter provides various scripts for interrogating these views to get all sorts of useful<br />

information about your database that you would otherwise have to obtain slowly, click<br />

by wretched click, from the sluggish SSMS Object browser. Once you've built up your<br />

own snippet or template library, you'll find it very easy to access your databases' metadata<br />

using <strong>SQL</strong> Code.<br />

226

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!