CREATE VIEW dbo.VIEW1
AS 
SELECT *
FROM (  SELECT 1 AS q_type, q_no ,q_difficult ,q_cha 
        FROM table1
        UNION
        SELECT 2 AS q_type, q_no ,q_difficult ,q_cha 
        FROM table2 ......) DERIVEDTBL

解决方案 »

  1.   

    create view dbo.v1 asselect q_no,q_difficult,q_cha,1 as q_type from table1
    unoin all
    select q_no,q_difficult,q_cha,2 as q_type from talbe2
    unoin all
    select q_no,q_difficult,q_cha,3 as q_type from table3
    unoin all
    select q_no,q_difficult,q_cha,4 as q_type from table4
    unoin all
    select q_no,q_difficult,q_cha,5 as q_type from table5
      

  2.   

    q_type是新建视图的列名,1,2,3,4,5是此列的值
      

  3.   

    create view 名
    as
    select table1.q_no,table2.q_difficult,table3.q_cha form table1 join table2 join table3 join table4 join table5 where table1.id=table2.id
      

  4.   

    每一个table都有q_no,q_difficult,q_cha字段