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 |
offspring22
Starting Member
38 Posts |
Posted - 2010-08-17 : 13:02:45
|
So I have a column named class, with data such as:DC (pre 1P2007)CC-MHC-COR1 f3.0h23|DC (pre 1P2007)R-1|M-1|S-UN|S-R|M-X1|R-2M|R-1s|R-1N|S-SPR|M-2 (pretc.What I need to do is select everything to the left of the first | in each row. So from the above, i'd be left with:DC (pre 1P2007)CC-MHC-COR1 f3.0h23R-1Any tips on how to do so? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-17 : 13:08:07
|
SELECT LEFT(field,CASE WHEN CHARINDEX('|',field)> 0 THEN CHARINDEX('|',field)-1 ELSE LEN(field) END)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|