How to query table data by Object Id and Column Id?
问题 Having the table Clients . PK LastName Name Address 1 Vidal Arturo St.... 2 Lavezzi Ezequiel St.... 3 Cuadrado Guillermo St.... I want to get: With the following query gives me the first four columns but how can I link this with the table data? SELECT TAB.object_id OBEJCTID, TAB.name TABLENAME, COL.column_id COLUMNID, COL.name FROM sys.tables TAB JOIN SYS.columns COL ON TAB.object_id = COL.object_id WHERE TAB.object_id = 25659888; 回答1: You need to unpivot the data. Try something like this