Create a view from two tables having different number of Columns

Answered Create a view from two tables having different number of Columns

  • 2012년 5월 7일 월요일 오전 7:17
     
     

    Hi,

    I want to construct a view in T-SQL by combining (like UNION ALL) two or more tables with different no. of columns.

    Eg. TABLE1 contains 3 columns (all VARCHAR) and 2 rows, TABLE2 contains 4 columns (all VARCHAR) and 4 rows. I would like the resultant view to be of 4 columns and 6 rows by combining these two tables. Retaining column names is not important

    PS :  These tables are determined dynamically, so there is no way of knowing how many columns would be there beforehand. The only guarantee is that the ALL THE COLUMNS would be of the type VARCHAR 


    • 편집됨 devROGUE 2012년 5월 7일 월요일 오전 7:21
    •  

모든 응답