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
 Import/Export (DTS) and Replication (2000)
 Selecting Text in SQL

Author  Topic 

billsack
Starting Member

35 Posts

Posted - 2006-05-03 : 12:27:02
Hey folks,

I have a query that is driving me nuts!

I want to select some text from a field before a comma. I have a text field with multiple information in it:

I.E.

|Dr Jim Watson, Grapefruit GP Surgery, 1 The Street]|

I just want to select the first part of the field (Dr Jim Watson) but can't rely on the Left function because this part can be all manor of lengths depending on the persons name!

Any help would be really appreciated.

Thanks alot

nr
SQLTeam MVY

12543 Posts

Posted - 2006-05-03 : 12:39:31
select left(fld, charindex(',',fld)-1)


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -