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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 split a column to 4 columns

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-03-07 : 08:43:29
ray writes "I have a sql server 2005 database with one address column. It is formatted as any address, any city, any state, any zip.
I need to split that address and each piece of info to 4 columns. One column for the address part, one for city, one for state, and one for zip codes. Thanks for your help."

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-07 : 09:22:52
make use of left(), right(), substring() etc to do it.


KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-07 : 09:39:33
Maybe some CHARINDEX/PATINDEX too?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2007-03-08 : 16:30:10
search fnSplitText in this forum

it takes a string and a separator and returns n-number of rows depending on how many splits you expected


HTH

--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -