Having a brain cramp here and don't know where to start. I have 2 tables:
vehicles and vehicle_useage. What I would like to do is this:
For each distinct vehicle in the vehicle table, I want to make entries for
each day of the month taken from a given date. This routine will be
scheduled to fire off once a month and populate the vehicle_useage table wit
h
vehicle use_dates for each day of the current month and for each VIN from th
e
vehicle table.
vehicle table:
VIN emp_id
-- --
VIN123456789 620123
VIN987654321 620123
vehicle_useage table:
use_date VIN miles
-- -- --
02/01/2006 VIN123456789 0
02/02/2006 VIN123456789 0
02/03/2006 VIN123456789 0
02/04/2006 VIN123456789 0
etc...
02/01/2006 VIN987654321 0
02/02/2006 VIN987654321 0
02/03/2006 VIN987654321 0
02/04/2006 VIN987654321 0
etc...
Much appreciated for any help you can give...Re-think your design. Why not just make an entry when the vehicle is
actually used?
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
.
"woodfoot" <woodfoot@.discussions.microsoft.com> wrote in message
news:760E1B4E-BD51-401B-A62B-DB68038881DB@.microsoft.com...
Having a brain cramp here and don't know where to start. I have 2 tables:
vehicles and vehicle_useage. What I would like to do is this:
For each distinct vehicle in the vehicle table, I want to make entries for
each day of the month taken from a given date. This routine will be
scheduled to fire off once a month and populate the vehicle_useage table
with
vehicle use_dates for each day of the current month and for each VIN from
the
vehicle table.
vehicle table:
VIN emp_id
-- --
VIN123456789 620123
VIN987654321 620123
vehicle_useage table:
use_date VIN miles
-- -- --
02/01/2006 VIN123456789 0
02/02/2006 VIN123456789 0
02/03/2006 VIN123456789 0
02/04/2006 VIN123456789 0
etc...
02/01/2006 VIN987654321 0
02/02/2006 VIN987654321 0
02/03/2006 VIN987654321 0
02/04/2006 VIN987654321 0
etc...
Much appreciated for any help you can give...|||I know what you are saying and I agree with you 110%. This is a temp
solution for something being re-designed anyway. It's life span may be 3
months max.
Sadly I must say, I just need a quick bandaid fix...
"Tom Moreau" wrote:
> Re-think your design. Why not just make an entry when the vehicle is
> actually used?
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> ..
> "woodfoot" <woodfoot@.discussions.microsoft.com> wrote in message
> news:760E1B4E-BD51-401B-A62B-DB68038881DB@.microsoft.com...
> Having a brain cramp here and don't know where to start. I have 2 tables:
> vehicles and vehicle_useage. What I would like to do is this:
> For each distinct vehicle in the vehicle table, I want to make entries for
> each day of the month taken from a given date. This routine will be
> scheduled to fire off once a month and populate the vehicle_useage table
> with
> vehicle use_dates for each day of the current month and for each VIN from
> the
> vehicle table.
> vehicle table:
> VIN emp_id
> -- --
> VIN123456789 620123
> VIN987654321 620123
> vehicle_useage table:
> use_date VIN miles
> -- -- --
> 02/01/2006 VIN123456789 0
> 02/02/2006 VIN123456789 0
> 02/03/2006 VIN123456789 0
> 02/04/2006 VIN123456789 0
> etc...
> 02/01/2006 VIN987654321 0
> 02/02/2006 VIN987654321 0
> 02/03/2006 VIN987654321 0
> 02/04/2006 VIN987654321 0
> etc...
> Much appreciated for any help you can give...
>|||woodfoot wrote:
> I know what you are saying and I agree with you 110%. This is a temp
> solution for something being re-designed anyway. It's life span may be 3
> months max.
> Sadly I must say, I just need a quick bandaid fix...
>
Replied in comp.databases.ms-sqlserver
Please don't multipost.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment