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日 上午 07: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日 上午 07:21
    •  

所有回覆