背景:
公司业务开发需要将两个取出两个相同表结构(原料、辅料)的数据,组成一个新视图,使用了UNION ALL
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO
CREATE view vw_rawmaterial_ny_list
as
(
select id,ccode,ccommtype,ccompany,ctypecode,cconneed,ccontype,ccorpcode,cdelay,cdepcode,cdepname,cmaker,cmakercode,cpaytype,cposcode,cprice,cstate,ctesttype,cweitype,ddate,cvencode,cvenname,cpurtype,ctimestamp from op_rawmaterial_ey
union all
select id,ccode,ccommtype,ccompany,ctypecode,cconneed,ccontype,ccorpcode,cdelay,cdepcode,cdepname,cmaker,cmakercode,cpaytype,cposcode,cprice,cstate,ctesttype,cweitype,ddate,cvencode,cvenname,cpurtype,ctimestamp from op_rawmaterial_ef
)
GO
介绍:
union all将两个结果集合并后就返回结果。因此,如果返回的两个结果集中有重复的数据,那么返回的结果就会包含重复的数据。