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 |
|
loner2003
Starting Member
3 Posts |
Posted - 2008-09-15 : 10:33:13
|
| I have some records I'm working with where the city and state are in the same column separated by a tab. I have been exporting results to Excel and doing text to columns to get rid of the state (it shows in another column in the query already), but I was wondering if there was a way to truncate or crop after the city name was complete. Here's an example:CORPUS CHRISTI (ten spaces) TXCan anyone help? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-15 : 10:45:09
|
CHARINDEX will find the position of the TAB, if present. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
loner2003
Starting Member
3 Posts |
Posted - 2008-09-15 : 11:24:51
|
how do I use it to trucate or crop the state out of my results? I am only interested in keeping the city name in the record.quote: Originally posted by Peso CHARINDEX will find the position of the TAB, if present. E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-15 : 11:27:27
|
SELECT Col1,LEFT(Col1, CHARINDEX(CHAR(9), Col1) - 1)FROM Table1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|