Red Gate forums :: View topic - Search DB Schema
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation

SQL Prompt code snippets forum

Search DB Schema

Search in SQL Prompt code snippets forum
Post new topic   Reply to topic
Jump to:  
Author Message
atomicbomb



Joined: 14 Feb 2008
Posts: 2

PostPosted: Thu Feb 14, 2008 5:17 am    Post subject: Search DB Schema Reply with quote

Description: Generates sql code to search the schema of a database, useful for big db's where tables have lots of columns, and you can't remember which table it's in Smile

Shortcut: sis (search in schema)

Code:
-- Set the database
Use [put your db here]

-- Exclude views and variable names
Select S.Name, T.Name, O.Name As [Object Name]
From SysColumns S
Inner Join SysObjects O on S.ID = O.ID
Inner Join SysTypes T On T.XType = S.XType
Where {(}S.Name Like '{%}name{%}'{)}
And {(}O.Name Not Like 'vw{%}'{)}
And {(}S.Name Not Like '@{%}'{)}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group