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.
| Author |
Topic |
|
billsack
Starting Member
35 Posts |
Posted - 2006-05-03 : 12:32:03
|
| 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 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-05-03 : 12:38:16
|
As a simple example...declare @s varchar(100)set @s = '|Dr Jim Watson, Grapefruit GP Surgery, 1 The Street]|'select substring(@s, 2, charindex(',', @s)-2)BUT is this really a text field, or simply a varchar?Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|