tags:

views:

108

answers:

2

How do I select all the tables name with a particular name in the database?

+6  A: 

Either sysobjects (where type='u'), or (more correctly) the info-schemas:

SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE '%CUSTOMER%' -- or "='CUSTOMER'" for exact

If you meant something different, please clarify.

Marc Gravell
+1 for using INFORMATION_SCHEMA - the SQL standardization way of doing things! :-)
marc_s
A: 
DECLARE @name nvarchar(100)
-- for SQL Server 2008
SELECT * FROM sys.all_objects WHERE name LIKE @name AND type IN ('U', 'S')

-- for others versions
SELECT * FROM dbo.sysobjects WHERE type IN ('U', 'S') AND name LIKE @name

Both scripts are included in Microsoft's scripts.

eKek0