Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-09-29 : 09:34:33
|
| I would appreciate some help with the following query.I have a table, tblRB_Facilities, each record being a different piece of equipment. I have another table, tblRB_FacilitiesDates. I want to run through tblRB_Facilities and add a record to tblRB_FacilitiesDates for every piece of equipment for every day, for a year from today, the key on tblRB_FacilitiesDates being Equipmentname*Date eg PrinterHP5*29/09/05TIA |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-29 : 09:41:08
|
| Here is a general approachUpdate T1 set T1.Col=T2.Col from tblRB_FacilitiesDates T1 inner join tblRB_Facilities T2on T1.Equipmentname=T2.EquipmentnameMadhivananFailing to plan is Planning to fail |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-09-29 : 09:50:25
|
| I want to insert a record, not update as tblRB_FacilitiesDates is empty. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-29 : 10:03:46
|
| Post some sample data and the result you wantMadhivananFailing to plan is Planning to fail |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-09-29 : 10:25:34
|
| tblRB_FacilitesFA_Id (autonumber key)FA_Item (nvarchar (100)eg 1 PrinterA 2 PrinterB 3 Laptop 4 ProjectortblRB_FacilitiesDatesFD_FaciltiesRef (Key)FD_DateRequired (datetime)FD_Item (nvarchar(100)FD_P1 (bit)FD_P2 (bit)....FD_P28I wantPrinterA*29/09/0529/09/05PrinterA00...etc to field FD_BP28this for each item in RB_Facilites and then to increment the date by 1 day and do it all again until I have a record for the next 365 days for each item.PrinterA*30/09/0530/09/05PrinterA00...etc to field FD_BP28Thanks for your help |
 |
|
|
|
|
|