BEGIN
IF @TransType = 1
BEGIN
SET IDENTITY_INSERT [dbo].[Sales.DeletedDeliveryHeaderHistory] ON
-- INSERT TO DELETE DELIVERY HEADER HISTORY
INSERT INTO @DRHeaderHist (RowID, CompanyName, ItemClassCode, DeliveryDate,
LoadingDate, DRNumber, Custnmbr, CustName,
TruckerID, PlateNumberID, TonnerID, DeliveryTypeID,
Remarks, DateCreated, DateModified, DatePosted,
UserName, FGUserName, DRUserName, PostedFG,
Import, CareOf, CareOfName )
SELECT *
FROM [Sales.DeliveryHeaderHistory]
WHERE DRNUMBER = @DR
INSERT INTO dbo.Sales.DeletedDeliveryHeaderHistory (RowID, CompanyName,
ItemClassCode, DeliveryDate, LoadingDate, DRNumber, Custnmbr,
CustName, TruckerID, PlateNumberID, TonnerID, DeliveryTypeID,
Remarks, DateCreated, DateModified, DatePosted, UserName,
FGUserName, DRUserName, PostedFG, Import, CareOf, CareOfName )
SELECT *
FROM @DRHeaderHist
SET IDENTITY_INSERT [dbo].[Sales.DeletedDeliveryHeaderHistory] OFF
SET IDENTITY_INSERT [dbo].[Sales.DeletedDeliveryDetailsHistory] ON
-- INSERT TO DELETE DELIVERY DETAIL HISTORY
INSERT INTO @DRDetailsHist ( RowID, CompanyName, DRNumber, OrderDocNum, OFLineNumber, LineNumber, Quantity, UofM, KgsPerBag, Itemnmbr,
TotalKgs, ItemDesc, VariantCode, VariantDesc, ProductionCode, OrderDate, DateNeeded, Week, Month1, PostedFG )
SELECT * from [dbo].[Sales.DeliveryDetailsHistory] WHERE DRNUMBER = @DR
INSERT INTO [dbo].[Sales.DeletedDeliveryDetailsHistory] ( RowID, CompanyName, DRNumber, OrderDocNum, OFLineNumber, LineNumber, Quantity, UofM, KgsPerBag, Itemnmbr,
TotalKgs, ItemDesc, VariantCode, VariantDesc, ProductionCode, OrderDate, DateNeeded, Week, Month, PostedFG )
SELECT * FROM @DRDetailsHist
SET IDENTITY_INSERT [dbo].[Sales.DeletedDeliveryDetailsHistory] OFF
END
END
这在存储过程查询中是否可能,因为我收到错误
消息 208,级别 16,状态 1,过程 SFC_spTransferDRtoDeleteArchives,第 85 行
无效的对象名称“dbo.Sales.DeletedDeliveryHeaderHistory”。
我正在尝试找到一种解决方案,用于在一个存储过程中为多个表上的多个数据传输创建存储过程,只是想知道它是否可能?或者可能有解决方案。