Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 merging like column values

Author  Topic 

tpotter1968
Starting Member

1 Post

Posted - 2009-06-26 : 23:58:54
I have a column called "DataSource"
Here are 3 examples of values from this column from 3 separate rows:

img244.ad.tim.com
img244.ad.tim.com/test
img244.ad.tim.com/name

If I do a select DISTINCT DataSource from tablename, obviously it will show all results above...what I need is one result specifying the servername portion and not the other data (the trailing slash and everything beyond it).

Any ideas?

Thanks

I would need this to come back:
img244.ad.tim.com


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-27 : 00:01:31
[code]
select distinct left(DataSource, charindex('/', DataSource + '/') - 1)
from tablename
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -