473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to convert columns to rows

4
Hi,

I have some procedures with dynamic sql(generic procedure for different tables) to do the convert columns to rows but have performance issue. Is there a better way like a single SQL that can solve my problem, thanks!!!

Table A(total 20 columns)
Col1 Col2 Col3 Col4 ... Col20

Table B(total 10 columns)
Col1 Col2 Col3 Col4... Col10

My procedure like this(pseudo code)
---------------------------------
for loop(table) <-- Loop Table A & B
for loop(loop records in the table) <-- Records in Table A & Table B
for loop(loop columns in a table) <-- No. of columns in Table
insert into a new_table(ColName, ColValue, current timestamp)
end for
end for
end for
Dec 21 '12 #1
1 6342
Rabbit
12,516 Expert Mod 8TB
Use a UNION query.
Dec 21 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Spiegel | last post by:
Hey all, I can't seem to find a way to determine how many columns or rows are in a multi-dimensional array. The Length and Rank properties would seem to help, but I can't seem to find that...
3
by: helpful sql | last post by:
Hi all, I am using an HTML table control on my ASP.Net page. Now I need to change this table so that columns become rows and rows become column. Since the table is very complex with many controls...
9
by: dotnetguru | last post by:
Hi SMART GUYS, Please help me write a query. Actually I want to convert my rows into columns. Can anyone kindly give me the query to do it? My rows are about employees. There can be any number of...
9
by: Classic-Car-World Ltd | last post by:
Hi, I have some data in a table in columns which I need to convert into rows. This is specification data for some tools etc. The data is currently in the following format: Product No, order,...
1
by: yusasen | last post by:
I have a table like this NO , CODE , NAME, CITY , COUNTRY 1 A1 CHARLY LONDON ENGLAND I want to get like this after query. 1 A1 CHARLY
1
by: lenygold via DBMonster.com | last post by:
Chris Eaton created a SP to to transpose rows to columns : Here is an example of a rowtocol stored proc that takes a SQL statement as the first paramter, a delimiter as the second parameter and the...
3
by: karimufeed | last post by:
I have an MS Access 2000 database It has an Applications table and an Applicants table. One Application ID may have many applicants attached. When creating a query by Application ID, one row is...
4
by: kevinkwh | last post by:
i wannn convert the following. thx in advance. data table desc nvarchar(100), amount numeric(18,2) FROM
7
by: Buyaa | last post by:
Hi all, Please help me. I want to convert all rows from my table into columns (to show on report). I tried pivot, but it is not suitable, there are no any aggregate column, i just need to directly...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.