|
USE [MAS90CBL]
GO
/****** Object: StoredProcedure [dbo].[sp_Refresh_MAS90CBLTables] Script Date: 6/13/2024 2:06:11 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Purnima>
-- Create date: <Create Date,,>
-- Description: <SO_SalesOrderHeader >
-- exec [dbo].[sp_Refresh_MAS90CBLTables_test];exec [dbo].[sp_Refresh_MAS90CBLTables];
--
-- =============================================
ALTER PROCEDURE [dbo].[sp_Refresh_MAS90CBLTables]
AS
BEGIN
Select * Into #SO_SalesOrderHeader
From [MAS90CBL].[dbo].SO_SalesOrderHeader
If exists (Select count(*) From #SO_SalesOrderHeader)
BEGIN
if OBJECT_ID('SO_SalesOrderHeader') Is Not Null
Drop Table SO_SalesOrderHeader
Select *
Into SO_SalesOrderHeader
From #SO_SalesOrderHeader
END
Select * Into #SO_SalesOrderHistoryDetail
From [MAS90CBL].[dbo].SO_SalesOrderHistoryDetail
If exists (Select count(*) From #SO_SalesOrderHistoryDetail)
BEGIN
if OBJECT_ID('SO_SalesOrderHistoryDetail') Is Not Null
Drop Table SO_SalesOrderHistoryDetail
Select *
Into SO_SalesOrderHistoryDetail
From #SO_SalesOrderHistoryDetail
END
Select * Into #SO_SalesOrderHistoryHeader
From [MAS90CBL].[dbo].SO_SalesOrderHistoryHeader
If exists (Select count(*) From #SO_SalesOrderHistoryHeader)
BEGIN
if OBJECT_ID('SO_SalesOrderHistoryHeader') Is Not Null
Drop Table SO_SalesOrderHistoryHeader
Select *
Into SO_SalesOrderHistoryHeader
From #SO_SalesOrderHistoryHeader
END
Select * Into #AR_InvoiceHistoryDetail
From [MAS90CBL].[dbo].AR_InvoiceHistoryDetail
If exists (Select count(*) From #AR_InvoiceHistoryDetail)
BEGIN
if OBJECT_ID('AR_InvoiceHistoryDetail') Is Not Null
Drop Table AR_InvoiceHistoryDetail
Select *
Into AR_InvoiceHistoryDetail
From #AR_InvoiceHistoryDetail
END
Select * Into #AR_InvoiceHistoryHeader
From [MAS90CBL].[dbo].AR_InvoiceHistoryHeader
If exists (Select count(*) From #AR_InvoiceHistoryHeader)
BEGIN
if OBJECT_ID('AR_InvoiceHistoryHeader') Is Not Null
Drop Table AR_InvoiceHistoryHeader
Select *
Into AR_InvoiceHistoryHeader
From #AR_InvoiceHistoryHeader
END
Select * Into #SO_SalesOrderDetail
From [MAS90CBL].[dbo].SO_SalesOrderDetail
If exists (Select count(*) From #SO_SalesOrderDetail)
BEGIN
if OBJECT_ID('SO_SalesOrderDetail') Is Not Null
Drop Table SO_SalesOrderDetail
Select *
Into SO_SalesOrderDetail
From #SO_SalesOrderDetail
END
Select * Into #AR_Customer
From [MAS90CBL].[dbo].AR_Customer
If exists (Select count(*) From #AR_Customer)
BEGIN
if OBJECT_ID('AR_Customer') Is Not Null
Drop Table AR_Customer
Select *
Into AR_Customer
From #AR_Customer
END
Select * Into #SO_ShipToAddress
From [MAS90CBL].[dbo].SO_ShipToAddress
If exists (Select count(*) From #SO_ShipToAddress)
BEGIN
if OBJECT_ID('SO_ShipToAddress') Is Not Null
Drop Table SO_ShipToAddress
Select *
Into SO_ShipToAddress
From #SO_ShipToAddress
END
Select ItemCode
,WarehouseCode
,TransactionDate
,TransactionCode
,EntryNo
,SequenceNo
,IMTransactionEntryComment
,APDivisionNo
,VendorNo
,ARDivisionNo
,CustomerNo
,ReferenceDate
,FiscalCalYear
,FiscalCalPeriod
,ShipToCode
,InvoiceType
,InvoiceHistoryHeaderSeqNo
,ReceiptHistoryHeaderSeqNo
,ReceiptHistoryPurchaseOrderNo
,TransactionQty
,AllocatedCost
,UnitPrice
,ExtendedPrice
,ExtendedStandardCost
,DateUpdated
,TimeUpdated
,UserUpdatedKey
,UDF_ACCOUNT
Into #IM_ItemTransactionHistory
From [MAS90CBL].[dbo].IM_ItemTransactionHistory
If exists (Select count(*) From #IM_ItemTransactionHistory)
BEGIN
if OBJECT_ID('IM_ItemTransactionHistory') Is Not Null
Drop Table IM_ItemTransactionHistory
Select *
Into IM_ItemTransactionHistory
From #IM_ItemTransactionHistory
END
Select ItemCode
,ItemType
,ItemCodeDesc
,ExtendedDescriptionKey
,UseInAR
,UseInSO
,UseInPO
,UseInBM
,CalculateCommission
,DropShip
,EBMEnabled
,PriceCode
,PrintReceiptLabels
,AllocateLandedCost
,WarrantyCode
,SalesUnitOfMeasure
,PurchaseUnitOfMeasure
,StandardUnitOfMeasure
,PostToGLByDivision
,SalesAcctKey
,CostOfGoodsSoldAcctKey
,InventoryAcctKey
,PurchaseAcctKey
,ManufacturingCostAcctKey
,TaxClass
,PurchasesTaxClass
,ProductLine
,ProductType
,Valuation
,DefaultWarehouseCode
,PrimaryAPDivisionNo
,PrimaryVendorNo
,ImageFile
,Category1
,Category2
,Category3
,Category4
,ExplodeKitItems
,ShipWeight
,CommentText
,RestockingMethod
,StandardUnitCost
,StandardUnitPrice
,CommissionRate
,BaseCommAmt
,PurchaseUMConvFctr
,SalesUMConvFctr
,Volume
,RestockingCharge
,ProcurementType
,DateCreated
,TimeCreated
,UserCreatedKey
,DateUpdated
,TimeUpdated
,UserUpdatedKey
,UDF_DISPOSITION
,UDF_WRITE
,UDF_INSPECT
,AllowBackOrders
,AllowReturns
,AllowTradeDiscount
,InactiveItem
,ConfirmCostIncrInRcptOfGoods
,LastSoldDate
,LastReceiptDate
,SalesPromotionCode
,SaleStartingDate
,SaleEndingDate
,SaleMethod
,NextLotSerialNo
,InventoryCycle
,RoutingNo
,PlannerCode
,BuyerCode
,LowLevelCode
,PlannedByMRP
,VendorItemCode
,SetupCharge
,AttachmentFileName
,ItemImageWidthInPixels
,ItemImageHeightInPixels
,LastTotalUnitCost
,SalesPromotionPrice
,SuggestedRetailPrice
,SalesPromotionDiscountPercent
,TotalQuantityOnHand
,AverageBackOrderFillDays
,LastAllocatedUnitCost
,TotalInventoryValue
,UDF_HTS_US
,UDF_PO_RECEIPT_NOTE
,UDF_HTS_EU
,UDF_LEAD_TIME
,UDF_EXPLODE_PL
Into #CI_Item
From [MAS90CBL].[dbo].CI_Item
If exists (Select count(*) From #CI_Item)
BEGIN
if OBJECT_ID('CI_Item') Is Not Null
Drop Table CI_Item
Select *
Into CI_Item
From #CI_Item
END
end
|