Our BA gave us Excel sheet with Two columns, column1
and column2
which I loaded in SQL Table. column1
contains distinct Values EmployeeID, FirstName, LastName, Address
and column2
contains respected values.
How do I convert Column1
distinct Values to Column so my table will have EmployeeID, FirstName, LastName, and Address
as columns?
File
Column1 || Column2
EmployeeID || 00251
FirstName || Joe
LastName || Reed
Address || 101 5th Ave
EmployeeID || 00145
FirstName || Jen
LastName || Smith
Address || 1001 Henderson RD
I am using the following query but it's giving an error.
SELECT pt.EmployeeID , pt.FirstName, pt.LastName, pt.[Address]
FROM
(
SELECT *
FROM FlatFile.UserList
) AS temp
PIVOT
(
MAX([COLUMN2])
FOR [COLUMNE1] IN ('EmployeeID','FirstName','LastName:','[Address]')
) as pt
Error:
Error Message:
Msg 102, Level 15, State 1, Line 11
Incorrect syntax near 'EmployeeID'.