This code defines a stored procedure named [dbo].[SFL_MIS_CollDataPull_SCUF_LCCBase]. Within the...

April 23, 2024 at 06:06 AM

Create Procedure [dbo].[SFL_MIS_CollDataPull_SCUF_LCCBase] As Begin Declare @m_ReportDt DateTime Set @m_ReportDt = GetDate() Update MIS_SFL_ScheduleTracker set PevCollPull_SCUF_Status='S',PevCollPull_SCUF_Start=GetDate() where convert(varchar(8),ReportDate,112)=convert(varchar(8),GetDate(),112) If Object_Id('SCUF_CollBase') Is Not Null Drop Table SCUF_CollBase If Object_Id('SCUF_CollBase1') Is Not Null Drop Table SCUF_CollBase1 If OBJECT_ID('PrevMonRepN') Is Not Null Drop Table PrevMonRepN If OBJECT_ID('PrevMonRepN1') Is Not Null Drop Table PrevMonRepN1 If OBJECT_ID('CurrMonRepN') Is Not Null Drop Table CurrMonRepN If OBJECT_ID('PrevMonRepN2') Is Not Null Drop Table PrevMonRepN2 If OBJECT_ID('PrevMonRepN3') Is Not Null Drop Table PrevMonRepN3 If OBJECT_ID('Tempdb.dbo.#Gu_Coll_Rep') Is Not Null Drop Table #Gu_Coll_Rep Declare @PrvMnthStDT DateTime,@PrvMnThendDT DateTime, @pCurrMnthStdt DateTime,@pCurrMnthEndDt DateTime ,@QryString Varchar(Max),@ProdCnt Int,@QryString1 Varchar(Max),@QryString2 Varchar(Max),@QryString3 Varchar(Max),@QryString4 Varchar(Max),@QryString5 Varchar(Max) ,@Qry1Tot Varchar(Max),@Qry2Tot Varchar(Max),@Qry3Tot Varchar(Max),@Qry4Tot Varchar(Max),@QryPTot Varchar(Max),@Product Varchar(2),@PrvProduct Varchar(2) ,@RepCnt Int,@RepDate Datetime,@RepFrmDt Varchar(8),@RepEndDt Varchar(8),@RepMnth Varchar(6),@RepoTable Varchar(Max),@RepoDB Varchar(Max) ,@JoinStr Varchar(Max),@JoinCond Varchar(Max),@PrvMnThendDT1 DateTime Set @QryString = '' Set @PrvProduct = '' If Convert(Varchar(2),@m_ReportDt,113)='01' Begin Set @PrvMnthStDT=Convert(Varchar(8),DATEADD(MONTH, DATEDIFF(MONTH, 0, @m_ReportDt-1)-1, 0),112) Set @PrvMnThendDT=Convert(Varchar(8),DATEADD(MONTH, DATEDIFF(MONTH, -1, @m_ReportDt-1)-1, -1),112) Set @pCurrMnthStdt = DATEADD(M,DATEDIFF(M,0,@m_ReportDt-1),0) Set @pCurrMnthEndDt = @m_ReportDt-1 Set @PrvMnThendDT1 = '2023.12.31' End

This code defines a stored procedure named [dbo].[SFL_MIS_CollDataPull_SCUF_LCCBase].

Within the procedure:

  • It initializes a variable @m_ReportDt with the current date and time.
  • Updates a row in the MIS_SFL_ScheduleTracker table, setting some columns based on the current date.
  • Drops several tables and temp tables if they exist.
  • Declares and initializes multiple variables for further use in the procedure.
  • Sets up various date calculations based on the current date stored in @m_ReportDt.
Generate your own explanations
Download our vscode extension
Read other generated explanations

Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node