Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.
The select part of this is basically an unmatched query, find all the records in T, that don't have a matching record in RT, and insert them into tbl_Readings_Tanks.
USE WHR_System_Tables DECLARE @AsOf as datetime2(7) SELECT @AsOf = NULL INSERT INTO tbl_Readings_Tanks (Equip_ID, docDate, Prod_ID, Inches_End, Closing_Vol) SELECT T.Equip_ID, T.DT_Recorded, T.Product_ID, T.Inches, T.Closing_Vol FROM ( SELECT ET.Equip_ID , CTRI.FacilityID , CTRI.DT_Recorded , CTRI.Product_ID , CTRI.TankNum , CTRI.Inches , ET.Diameter , Closing_Vol = (CTRI.Inches/12) * (3.14159 * (ET.Diameter/2) * (ET.Diameter/2)) * 0.17811 FROM dbo.vw_Equipment_Tanks as ET INNER JOIN dbo.vw_Cygnet_Tank_Readings_Inches as CTRI ON ET.DS_PK_Text = CTRI.FacilityID AND ET.Product_ID = CTRI.Product_ID AND ET.Tank_Num = CTRI.TankNum WHERE (@AsOf IS NULL) OR (CTRI.Dt_recorded > @AsOf) ) as T LEFT JOIN tbl_Readings_Tanks as RT ON T.Equip_ID = RT.Equip_ID AND T.DT_Recorded = RT.docDate WHERE RT.TankReadingID IS NULL
|SQL Select end of week date from last year||6||39|
|Change variables in SQL table||6||51|
|How to filter an ASP.Net GridView using a CheckBoxList||7||38|
|Start a field with integer 1||7||27|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
7 Experts available now in Live!