Conversion of vertical data to horizontal in sql: Today I am going to
show you how to convert vertical data to horizontal in ms sql. Here we have
multiple ways by which we can convert vertical data to horizontal in sql. Here are some simple transformation of data from vertical to horizontal.
Table structure
Insert Some data in table and select it
Method1: to convert vertical data to horizontal in sql
Method2: to transformation of vertical data to horizontal in sql
It will show the record is in form of XML
Table structure
Insert Some data in table and select it
Method1: to convert vertical data to horizontal in sql
Select * from PartsItem
Declare @ProductSKU varchar(MAX)=' '
select @ProductSKU= @ProductSKU+ ISNULL
(ProductSKU+', ' , ' ') from PartsItem Select @ProductSKU as ProductSKUCode
Method2: to transformation of vertical data to horizontal in sql
It will show the record is in form of XML
Select ProductSKU
+ ' , ' from PartsItem for xml path (' ')
Post a Comment