Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Locate a column across databases

By Douglas Osborne,

This will search for a column across all databases.

You must specifiy the exact column spelling.

After that, you can get creative. If you have a number of databases, perhaps versioned by release, you can specifiy a @Branch suffix - so by passing in 0010 you would match

MyDatabase0010

MyBills0010

MyInvoice0010.

You can specify an exact databasse via @DB, and can specify if you want to see all matches, all tables, or all views.

Examples

EXECUTE dbo.LocateColumnDefinitions @Column = 'AccountID', @Branch = '0099'

EXECUTE dbo.LocateColumnDefinitions @Column = 'Address1', @DB = 'DATASERVICES'
EXECUTE dbo.LocateColumnDefinitions @Column = 'AccountID', @ViewTableAll = 'V'
EXECUTE dbo.LocateColumnDefinitions @Column = 'InsertDate',@ViewTableAll = 'V', @Branch = '0099

Total article views: 1201 | Views in the last 30 days: 1
 
Related Articles
ARTICLE

The Complexity of Branches

Branching code creates complexity to development and should be undertaken with caution.

FORUM

SSIS Branching

want ability to branch to one of two pathways defined by a variable

BLOG

Picking a Branch

Do you know that there are actually two branches of SQL Server 2008 code right now? Actually I would...

FORUM

execution plan

execution plan

FORUM

execution plan

execution plan

Tags
columns    
database    
search    
utility    
 
Contribute