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 |
|
gagani
Posting Yak Master
112 Posts |
Posted - 2012-04-03 : 07:07:04
|
| For the input table100 BD23 2DB101 BD3 4ZX102103 AX2 43Z104 SW19 4ZBhow to get part of the postcode(part before the space of the postcode) like this100 BD23 101 BD3 102103 AX2 104 SW19 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-04-03 : 07:34:58
|
| [code]CASE WHEN CHARINDEX(' ',Col2) > 0 THEN LEFT(@x,CHARINDEX(' ',Col2)-1) ELSE Col2 END[/code]This takes care of cases where there is no space as well. |
 |
|
|
|
|
|