I have a table with columsn employee number, col1, col2, col3, col4, col5. Call this table 'OLDTABLE'
eg of a record:
Employee number | Col1 | Col2 | Col3 | Col4 | Col5
---------------
123455 x y z a b
Call this new table 'NEWTABLE'. I have to tranfer the data from the above table in a new one that shud look like employee number, col. the above example shud look like:
Employee number | Col
--------
123455 x
123455 y
123455 z
123455 a
123455 b
I was looking for a SQL for such a task.
ThanksINSERT INTO NEW
SELECT EmpId, Col1
FROM OLD
UNION ALL
SELECT EmpId, Col2
FROM OLD
UNION ALL
SELECT EmpId, Col3
FROM OLD
UNION ALL
SELECT EmpId, Col4
FROM OLD
UNION ALL
SELECT EmpId, Col5
FROM OLD|||thanks great brettsql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment