sql server - How do I split an address string in T-SQL? -


I want to split a column into 4 columns based on the column. Example: 'City_name', 'state', 'zip' code, 'country' in column value:

I call it 4 different columns such as City_Name , state , zipcode , country .

How can I do this by using T-SQL?

Assuming that you always have 3 commas in that column, you can use the function

  Table # Test Creation (Colonel Curse (100) ) Insert Personnel (Colonel, ',', '.'), 4) Name of the city as the name (pattern (colonel, ',', '.'), 3) state, (Q Name (Colonel, ',', '.'), 2) In the form of a zipod, the name (replacements (colonel, ',', '.'), 1) #test as the country  

Output

  City_Name State Zipcode Country New York City NJ 10028 United States Es 

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -