I have a challenging SQL query to work out (SQL Server).
I have one table that will show mappings between the two tables.
So below, field F1 is a scanner id
and table two, has the scanner Id in F1. F2 has the Location, and so on.
The top table can be updated to change mappings at any time.
So my question is how do I create a query so I know what field name relates to what data in table two.
I started off with an UNPIVOT, but didn't get too far as yet. If I could get the field name in the unpivot results then I am a long way to solving it.
SELECT ID, Data FROM ( select ID,[F1] ,[F2] ,[F3] ,[F4] ,[F5] ,[F6] ,[F7] ,[F8] ,[F9] ,[F10] FROM [Inventory].[dbo].[ScannedDataCapture] ) AS cp UNPIVOT ( Data FOR Datas IN ([F1] ,[F2] ,[F3] ,[F4] ,[F5] ,[F6] ,[F7] ,[F8] ,[F9] ,[F10]) ) AS x
Thanks upfront. Scott