Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is the data
HTML
Table Name        Total count       Matched
Material Master	    58941	     30092 
rxml_values	    512218	     466637
Materialdetail      56141            3090 
values details      533218           478637


But I want out put data is:

Table Name: Material Master
Total count: 58941
Matched: 30092
Table Name: rxml_values
Total count: 512218
Matched : 466637
Table Name :Materialdetail
Total count: 56141
Matched : 3090
Table Name: values details
Total count: 533218
Matched : 478637



C#
SQL, SQL-server-2008R2, MySQL, Access, Excel, 


if any one database to change this..?
Posted
Comments
Herman<T>.Instance 8-Jan-16 4:44am    
search for UNPIVOT command

1 solution

in simple way, you can get the result using below query

SQL
DECLARE @tbl AS TABLE (Table_Name NVARCHAR(50),Total_count INT,Matched INT)

INSERT INTO @tbl                
SELECT 'Material Master',58941,30092 UNION ALL 
SELECT 'rxml_values',512218,466637 UNION ALL 
SELECT 'Materialdetail',56141,3090  UNION ALL 
SELECT 'values details',533218,478637

select val from 
(
select 'A' AS sr, Table_Name, 'Table_Name:' + Table_Name As val
FROM @tbl
UNION
select 'B' AS sr, Table_Name, 'Total_count:' + CAST(Total_count AS NVARCHAR(50)) As val
FROM @tbl
UNION
select 'C' AS sr, Table_Name, 'Matched:' + CAST(Matched AS NVARCHAR(50)) As val
FROM @tbl
) as tbl order by Table_Name,sr



Her is the result of above query -

SQL
Table_Name:Material Master
Total_count:58941
Matched:30092
Table_Name:Materialdetail
Total_count:56141
Matched:3090
Table_Name:rxml_values
Total_count:512218
Matched:466637
Table_Name:values details
Total_count:533218
Matched:478637
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900