Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

CSV to Multiple Columns

Aug 27 2007 9:30AM by Madhivanan   

If the table is denormalised and has Comma Seperate Values in acolumn, this code will copy it to Multiple columns of aNormalised table

declare @DeNormalisedTable table(data varchar(8000))

insert into @DeNormalisedTable 
select '1,Davolio,Nancy' union all
select '2,Fuller,Andrew' union all
select '3,Leverling,Janet' union all
select '4,Peacock,Margaret' union all
select '5,Buchanan,Steven' union all
select '6,Suyama,Michael' union all
select '7,King,Robert' union all
select '8,Callahan,Laura' union all
select '9,Dodsworth,Anne'

select * from @DeNormalisedTable -- Comma Seperated Values

declare @s varchar(8000), @data varchar(8000)

Create table #NormalisedTable (Code int, FirstName varchar(100), LastName varchar(100))

select @s=''
while exists (Select * from @DeNormalisedTable where data>@s)
Begin
        Select @s=min(data) from @DeNormalisedTable where data>@s
        select @data=''''+replace(@s,',',''',''')+''''
        insert into #NormalisedTable 
        exec('select '+@data)
End 
select * from #NormalisedTable -- Data in Normalised Table

/*
--Result
---------------------------
Code  FirstName  LastName
---------------------------
1	  Davolio		Nancy
2	  Fuller		Andrew
3	  Leverling		Janet
4	  Peacock		Margaret
5	  Buchanan		Steven
6	  Suyama		Michael
7	  King			Robert
8	  Callahan		Laura
9	  Dodsworth		Anne
*/

drop table #NormalisedTable

Tags: t-sql, sql_server, csv, split, multiple_column,


Madhivanan
3 · 40% · 12909
1 Readers Liked this
Jacob Sebastian Liked this on 4/9/2012 6:53:00 AM
Profile · Blog · Facebook · Twitter
1
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"CSV to Multiple Columns" rated 5 out of 5 by 1 readers
CSV to Multiple Columns , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]