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 |
GaryNull
Starting Member
14 Posts |
Posted - 2012-12-11 : 21:23:38
|
Hi,I need to extract all the text before the first dash.For example the fields :COBRA DIGITAL - DPS-2300 WAND becomesCOBRA DIGITALandROYAL - 29421NbecomesROYALCan anyone help? thanks |
|
singularity
Posting Yak Master
153 Posts |
Posted - 2012-12-11 : 21:30:25
|
select left(yourfield, charindex('-',yourfield)-1)from yourtable |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-11 : 21:31:20
|
[code]Select Substring(columnname,1,Charindex('-',columnname)-2) from Table[/code] |
|
|
GaryNull
Starting Member
14 Posts |
Posted - 2012-12-11 : 22:02:21
|
thanks guys, both worked perfectly |
|
|
|
|
|