Author |
Topic |
Patyk
Yak Posting Veteran
74 Posts |
Posted - 2014-03-07 : 14:59:51
|
I like to know if i can modify my procedure to acually insert data from more than one table. The second table DS_Control table is not linked with the other table. It only contains one line.BEGININSERT INTO Reporting.dbo.DailyWarehouseValues (FiscalYear,FiscalMonth,EntryDate, StockCode ,Warehouse,QtyOnHand,QtyAllocated,QtyOnOrder,QtyOnBackOrder,QtyInTransit,QtyAllocatedWip)Select FYear, FMonthFROM Reporting.dbo.DS_ControlTable;Select GETDATE(), StockCode ,Warehouse,QtyOnHand,QtyAllocated,QtyOnOrder,QtyOnBackOrder,QtyInTransit,QtyAllocatedWipFROM companyB.dbo.InvWarehouse;WHERE Warehouse in ('01', '02', '03')END |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-03-07 : 15:09:08
|
You might need to add TOP 1, see if this works:INSERT INTO Reporting.dbo.DailyWarehouseValues (FiscalYear,FiscalMonth,EntryDate, StockCode ,Warehouse,QtyOnHand,QtyAllocated,QtyOnOrder,QtyOnBackOrder,QtyInTransit,QtyAllocatedWip)Select (Select FYear FROM Reporting.dbo.DS_ControlTable), (Select FMonthFROM Reporting.dbo.DS_ControlTable), GETDATE(), StockCode ,Warehouse,QtyOnHand,QtyAllocated,QtyOnOrder,QtyOnBackOrder,QtyInTransit,QtyAllocatedWipFROM companyB.dbo.InvWarehouse;WHERE Warehouse in ('01', '02', '03')Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|