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 2000 Forums
 Transact-SQL (2000)
 Partial Select

Author  Topic 

KenA
Starting Member

28 Posts

Posted - 2006-10-04 : 15:59:36
Hi. Suppose I have a table where the description column has a pair value string separated by a comma:

[Descrition Column]
DEF LEPPARD , Historia / In The Round In Your Face
DEF LEPPARD , Live In Japan, Euphoria Tour 1999
DEF LEPPARD , Live In Toronto 1983
DEF LEPPARD , Visualize / Video Archive
...etc

How can I select just 'DEF LEPPARD' or just the right side of the comma?

»»» KenA

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-10-04 : 16:11:48
SELECT LEFT(YourColumn, PATINDEX('%,%', YourColumn) - 1)
FROM YourTable

Tara Kizer
Go to Top of Page

KenA
Starting Member

28 Posts

Posted - 2006-10-04 : 17:01:24
Thanks Tara :-)
Another option I´ve found, is to use a custom split function like: http://weblogs.asp.net/pleloup/archive/2003/04/14/5569.aspx

»»» KenA
Go to Top of Page
   

- Advertisement -