Query the SQL Server Schemea

 

— query via information scheme
use <dbname>
GO;

SELECT top 10 * FROM INFORMATION_SCHEMA.TABLES
select top 10 * from INFORMATION_SCHEMA.VIEWS
SELECT top 10 * FROM INFORMATION_SCHEMA.COLUMNS
select top 10 * from INFORMATION_SCHEMA.PARAMETERS
select top 10 * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
select top 10 * from INFORMATION_SCHEMA.CONSTRAINT_TABLE_USAGE

— sys.objects
use <dbname>
GO;

select top 10 * from <dbname..sys.procedures
select top 10 * from <dbname>sys.tables
select top 10 * from <dbname>sys.columns
select top 10 * from <dbname>sys.views

— object definition
use <dbname>
GO;

SELECT name, OBJECT_DEFINITION(OBJECT_ID), *
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE ‘%foo%’

— sysobjects/syscolumns
use <dbname>
GO;

SELECT objParent.name AS parent, obj.name
FROM sysobjects obj
LEFT JOIN syscolumns col
ON obj.id = col.id
LEFT JOIN sysobjects objParent
ON objParent.id = obj.parent_obj
WHERE col.name LIKE ‘%foo%’
OR obj.name LIKE ‘%foo%’

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s