Link to home
Start Free TrialLog in
Avatar of GPSPOW
GPSPOWFlag for United States of America

asked on

Union 4 Sql views into one temporary table

I have the attached code to union 4 SQL views into a temporary table but I can't get the correct syntax.  Please help.
/****Combine PM Balance and CM transactions into one table********/
SELECT  [PeriodDateTime]
      ,[PMBal]
      ,[PEStatus]
      ,[AccountNumber]
      ,[TxnAmount]
      ,[CAmt]
      ,[BDAmt]
      ,[CurStatus]
      
  into #Rollup
  FROM [livedb].[dbo].[vw_DAILY_ROLLUP_PEBAL]
  
  union
  
  SELECT DATEADD(mm,datediff(mm,0,getdate()),0) as PeriodDateTime
  ,[PEBal]
  ,[PEStatus]
  ,[AccountNumber]
  ,[TxnAmount]
      ,[CAmt]
       ,[BDAmt]
      ,[CurStatus]
      
      
      
   
  FROM [livedb].[dbo].[vw_DAILY_ROLLUP_CHARGES]
  
  union
  
  SELECT DATEADD(mm,datediff(mm,0,getdate()),0) as PeriodDateTime
  ,[PEBal]
  ,[PEStatus]
  ,[AccountNumber]
  ,[TxnAmount]
      ,[CAmt]
       ,[BDAmt]
      ,[CurStatus]
     
  FROM [livedb].[dbo].[vw_DAILY_ROLLUP_COLLTXNS]
  
  union
  SELECT DATEADD(mm,datediff(mm,0,getdate()),0) as PeriodDateTime
  ,[PEBal]
  ,[PEStatus]
  ,[AccountNumber]
  ,[TxnAmount]
      ,[CAmt]
       ,[BDAmt]
      ,[CurStatus]
  
  
   FROM [livedb].[dbo].[vw_DAILY_ROLLUPS_BDXFER]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial