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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

269<br />

Chapter 9: Searching DDL and Build Scripts<br />

UNION ALL<br />

SELECT Specific_Catalog + '.' + Specific_Schema + '.' + Specific_Name<br />

+ '(' + Parameter_name + ')' ,<br />

'routine parameter'<br />

FROM information_schema.parameters<br />

WHERE parameter_name ''<br />

AND parameter_name LIKE @SearchString<br />

UNION ALL<br />

SELECT Table_Catalog + '.' + Table_Schema + '.' + Table_Name + '.'<br />

+ Column_Name ,<br />

'column Name'<br />

FROM INFORMATION_SCHEMA.COLUMNS<br />

WHERE column_name LIKE @SearchString<br />

UNION ALL<br />

SELECT Table_Catalog + '.' + Table_Schema + '.' + Table_Name + '.'<br />

+ Column_Name + '.default' ,<br />

'default constraint text'<br />

FROM INFORMATION_SCHEMA.COLUMNS<br />

WHERE column_default LIKE @SearchString<br />

Listing 9-1: Searching your database using INFORMATION_SCHEMA views.<br />

Learning patience: using SMO<br />

You can get a huge range of database and server objects with SMO, as long as you don't<br />

mind waiting, and if you like coding in a .NET language. The problems come when<br />

you try to tackle a large database. You are soon in trouble if you have a lot of tables and<br />

columns, because you have to walk the hierarchy of SMO objects, rather than do a setoriented<br />

operation. SMO provides a logical and consistent interface into a database,<br />

but it does not represent the reality of the way that this information is actually stored<br />

in the database.<br />

SMO comes into its own as a way of quickly finding out how to access a "difficult" database<br />

object. If you use SMO, and run Profiler at the same time, to see what <strong>SQL</strong> is being<br />

executed as a result of running an SMO job, you can quickly achieve <strong>SQL</strong> MegaStar status<br />

in your development team.

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

Saved successfully!

Ooh no, something went wrong!