Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select distinct table names in SQL Server7.0 1

Status
Not open for further replies.

rtshort

IS-IT--Management
Joined
Feb 28, 2001
Messages
878
Location
US
I have a database in which a lot of the tables have similar names. For example a table named :

"76 Mercury Starter"
"76 Mercury Engine"
"76 Mercury Exhaust"
"98 Ford Starter"
"98 Ford Engine"
"98 Ford Exhaust"

and so forth.

How would I select Distinct table names from the database and only get one Mercury and one Ford in the query results?

I have tried "select Distinct Name from sysobjects where type like 'U'" but it still comes up with all of the tables. Any help is greatly appreciated.
Rob
Just my $.02.
 
The problem u have is that there are number values along with character in table name.

This can help u build some more ideas.
select * from sysobjects where difference(('client'),ltrim(name)) > 3
The above uses a difference which will give a relative measure.As the measure value increases the inference is that name matches more.

select * from sysobjects where name like '%client%'

Pls go thro some string functions in SQL BOL which may help u.
 
Thanks for the reply. I'll have a look at SQL BOL. Your post however, pointed me in the right direction.
Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top