Board index » delphi » Searching MS SQL for tables containing a given string in their name

Searching MS SQL for tables containing a given string in their name


2004-03-02 11:02:54 PM
delphi181
I got this SQL from someone here a while back for finding all COLUMNS
containing a given string from an MS SQL Server database:
select
sysobjects.Name As TableName,
syscolumns.Name as ColumnName
from
sysobjects,
syscolumns
where
sysobjects.id = syscolumns.id and
sysobjects.xtype = 'U' and /* Tables Only ?*/
syscolumns.Name like 'WRBL_MCG' /* Name to search for */
order by
sysobjects.Name,
syscolumns.Name
Can anyone tell me the SQL needed to find TABLE names containing a given
string--does sysobjects.id get changed to systables.id or some such?
Also, regarding xtype: what does 'U' mean, and what other values are
available?
--
Clay Shannon,
author of the novel "the Wacky Misadventures of Warble McGorkle"
www.booksurge.com/author.php3
 
 

Re:Searching MS SQL for tables containing a given string in their name

try
select * from sysobjects
where xtype='U'
and name like '%Name%'
S-->System Table
PK-->Primary Key
P-->Procedure
V-->View
UQ-->Unique index
TR-->Trigger
D-->Default
X-->Extended Procedure
FN-->User Function
TF-->System Function
F-->Foreign Key
C-->Contraint
"Clay Shannon" <XXXX@XXXXX.COM>wrote in
message news:4044a256$XXXX@XXXXX.COM...
Quote
I got this SQL from someone here a while back for finding all COLUMNS
containing a given string from an MS SQL Server database:

select
sysobjects.Name As TableName,
syscolumns.Name as ColumnName
from
sysobjects,
syscolumns
where
sysobjects.id = syscolumns.id and
sysobjects.xtype = 'U' and /* Tables Only ?*/
syscolumns.Name like 'WRBL_MCG' /* Name to search for */
order by
sysobjects.Name,
syscolumns.Name

Can anyone tell me the SQL needed to find TABLE names containing a given
string--does sysobjects.id get changed to systables.id or some such?

Also, regarding xtype: what does 'U' mean, and what other values are
available?

--
Clay Shannon,
author of the novel "the Wacky Misadventures of Warble McGorkle"
www.booksurge.com/author.php3