Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help Parsing CityState
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01448886
Message ID:
01448956
Vues:
40
>Ok, now assuming I already had City & State columns, how would I use this logic to update those 2 fields from CityState?
>
>

Ok, never mind.
update myTable set City = charindex(' ',reverse(CityState)), substring(CityState, 1, 
case when charindex(' ',reverse(CityState)) = 0 then len(CityState) 
else len(CityState) - charindex(' ',reverse(CityState)) end), state = 
SUBSTRING(CityState, case when charindex(' ',reverse(CityState)) = 0 then len(CityState) +1 else 
len(CityState) - charindex(' ',reverse(CityState))+2 end, LEN(CityState)) 
>>Interesting, I thought substring (@Var, len(@Var), len(@Var)) will give you an empty string.
>>
>>
>>I can say, I have blonde moments myself :)
>>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform