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 |
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2008-12-02 : 04:59:10
|
| Hi I have a text field with a value like this'Product A :(Peter perfect)'I want to use substring to get the first part out (i.e. 'Product A')But i am having a bit of a mental block.I know it's something like thisSubstring(field1,1,?????)I tried using LEN but couldn't make it work.Any help appreciated |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-02 : 05:00:06
|
CHARINDEX. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-02 : 05:03:32
|
| [code]SELECT LEFT(field,CASE WHEN CHARINDEX(':',field)>0 THEN CHARINDEX(':',field)-1 ELSE LEN(field) END) FROM table[/code] |
 |
|
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2008-12-02 : 05:15:01
|
| Much appreciatedI was also tring instr and instring before realising that they can't be used in MSSQLthanks again |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-02 : 06:11:00
|
quote: Originally posted by icw Much appreciatedI was also tring instr and instring before realising that they can't be used in MSSQLthanks again
They are VB functions. |
 |
|
|
|
|
|