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 |
rkruis
Starting Member
28 Posts |
Posted - 2011-10-11 : 13:53:39
|
I have a table with a few fields. One of the fields (Abstract) is a 255 char with example data shown below. Each of the records is prefixed with a string and then a dash.I would like to return all unique prefixes before the dash. Is there a way to do this?DataIDX Abstract121 ACC - a string of text122 ACC - a string of text123 ABAC - a string of text124 DEEF - a string of text125 ABBDE - a string of text126 ACC - a string of text127 ABBDE - a string of textReturn (Just the prefixes not duplicated)ABACDEEFABBDEACC |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-11 : 14:19:24
|
yup. do likeSELECT DISTINCT LEFT(Abstract + ' - ',CHARINDEX(' - ',Abstract + ' - ')-1)FROM Data ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
rkruis
Starting Member
28 Posts |
Posted - 2011-10-11 : 17:20:13
|
Thank you very much. I will try this tonight :) |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-12 : 01:25:18
|
welcomelet me know how you got on------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|