Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I have a column in database that has some data seperated by spaceexample: 0001 000 0000 0002 01010 000I want to split them into three seperate columns in a report I am generating using sql. Any help on this is really appriciated.Thank you
Cindyaz
Yak Posting Veteran
73 Posts
Posted - 2011-10-26 : 09:10:50
Write a split function.[url]http://searchsqlserver.techtarget.com/tip/Using-split-delimiter-separated-lists-in-SQL-Server [/url]
if format is consistent with always three parts, use
select parsename(replace(yourcolumn,' ','.'),3) as first,parsename(replace(yourcolumn,' ','.'),2) as second,parsename(replace(yourcolumn,' ','.'),1) as thirdfrom table
------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/