库1和库2在同一服务器上。。
现在要把在库1查询的和查询的记录合并建立个视图放在库1中。。如何建立???

解决方案 »

  1.   

    先建Database link
    链接服务器
      

  2.   

    create view V_Test
    asselect * from 表名
    union allselect * from 其它库名.dbo.表名
      

  3.   

    select * from 表名 where..
    union allselect * from 其它库名.dbo.表名 where ...这个where是统一在后面写还是分开写???
      

  4.   

    使用union all要字段列完全相同的情况下
      

  5.   

    用select *可以吗,这样要两个表的结构一样吧。
    where要分开写