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 |
swingjive
Starting Member
1 Post |
Posted - 2008-06-16 : 12:17:45
|
I am new to SQL in general. I am still working in Access, but I want to write an SQL script to add a certain number of rows based on two criteria.I have one table with all the information in it. The two main fields are #tubes and #fibres per tube. (fibre optics).The maximum number of tubes I can have is 24, and the maximum # of fibres per tube is 12. But sometimes there are 4 fibres in a tube, sometimes 6, sometimes 12, etc. So if my default table has 24 tubes of 12 (288), but I want to add a record that has 9 tubes and there are 4 fibres in each tube (36F cable), it knows to select 9 tubes, but only the first 4 records in that tube.I am not sure if I am explaining this very well, but if this makes sense, I would appreciate some insight.I want this script to add this new information to an existing table. The table is all based on an ID code for the cables so if I add the cable above, 36F, 9 tubes, 4 fibres per tube, it will add 36 rows of data to my table, and the ID code for all 36 rows will be the same so if I do a report for that cable, it will look for all the records with that ID code, and display the resuts.I have this working with a whole whack of queries, and a few templates and a criptic Macro, but to get it working properly and make it user friendly, I'll need many more queries and probably around 20 template tables. It's time much of this database was transferred into SQL though.I imagine the code would do something like this with various options.If #of fibres = 36 #of fibres per tube = 4, then it would do a calculation (36/4 to get number of tubes), then it would take the first 6 tubes, then the first 4 lines in each tube, and give me a total of 36 new rows in my existing table.If I had a 24F cable with 6 fibres in each, it would know that there are 4 tubes, and take the first 4 tubes, and the first 6 fibres in each tubes, giving me 24 total new rows.Thanks for your time. |
|
|
|
|
|
|