我有大約200列的表,所以我想知道下面是否有可能:SQL查詢從另一個表中檢索每列的所有值?
考慮下表,我們稱之爲PersonInformation:
PersonId AgeCode NeighbourhoodCode DogFlagCode ...
1 5 8 10
2 1 9 11
3 5 8 10
考慮其他表,讓我們稱之爲InformationValues
Id Value
5 21
1 22
8 Neighbourhood A
9 Neighbourhood B
10 Dog present
11 Dog not present
現在我想做的就是創建一個視圖,顯示這一點:
PersonId AgeCode NeighbourhoodCode DogFlagCode ...
1 21 Neighbourhood A Dog present
2 22 Neighbourhood B Dog not present
3 21 Neighbourhood A Dog present
由於有大約200列可以使用Microsoft SQL Server Management Studio使用生成腳本來執行此操作嗎?或者這是可能的普通SQL?
這裏是棘手的部分:一些表格不具備代碼後綴不能被搜索和它們的值列。
我一直在努力研究這個問題,但除了手動完成之外,我找不到任何其他的東西。
更新1 至於我手動定義爲「手動輸入所有列名稱」之前的句子。
感謝
我覺得*「沒有代碼後綴不能被搜索和它們的值列一些表。 「* 是錯的。也許你想說的是「一些有代碼後綴[...]的列」? – 2015-03-19 12:52:29
是的,這是放置它的另一種方式,但那些沒有代碼後綴的列不需要查找「真實值」。 – Snowflake 2015-03-19 13:26:29