I’m currently training for the Medtronic Twin Cities Marathon on 10/3/10 and raising money for the American Cancer Society.
The details, along with some fun stuff can be found here:
|
||||
|
I’m currently training for the Medtronic Twin Cities Marathon on 10/3/10 and raising money for the American Cancer Society. The details, along with some fun stuff can be found here:
I’m a runner as well as a DBA. I’ve got a marathon this weekend, so I started thinking about how SQL and running are similar.
I’ve updated the script for Running Events to use the time data type for SQL2008. Also here’s a little script I used to track my goal of running 200 miles in May. It gives a visual graph of actuals vs goal as well as percentage of month used.
Set nocount on
Declare @miles float
Declare @Goalmiles int
Declare @divisor int
--Change these based on your milage/goal
Set @miles = (8+10+11+16+12+10+13.5+22+11+11+11)
Set @Goalmiles = 200
Set @divisor = 2
Select Replicate('@', @Goalmiles/@divisor)
+ Char(13) + Char(10) +
Replicate('@', @miles/@divisor) + ' -- ' + convert(varchar(10), @miles/@Goalmiles) + '%'
+ Char(13) + Char(10) +
convert(varchar(10), @miles) + ' of ' + convert(varchar(10), @Goalmiles) as 'Progress'
--Find the percentage of the month gone
Select round(datepart(D, GETDATE())/convert
(float, datepart(D, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0)))), 4)
as '%ofMonth'
Here’s a script I created to determine when I was going to be at specific miles for a marathon. It’ll give you your miles per hour and your minutes per mile. Then it’ll calculate at what time you will be at different mile marks. Set nocount on Declare @FTime datetime, @Dist float, @RStartTime datetime, @BDown float ----------------------------------- ----Change these for you event----- ----------------------------------- Set @FTime = '3:10:00' Set @Dist = 26.4 Set @RStartTime = '6/19/10 7:30 AM' Set @BDown = 1 --this is the breakdown desired ----------------------------------- ----------------------------------- ----------------------------------- Declare @Htime int, @Mtime int, @STime int, @TSec int, @SPM float, @iCounter float Declare @TheList table (Mile float, RTime datetime, CrossingTime time) Set @Htime = Datepart(hh, @FTime) Set @Mtime = Datepart(mi, @FTime) Set @Stime = Datepart(ss, @FTime) Set @TSec = (@Htime*60*60) + (@Mtime*60) + @Stime Set @SPM = @TSec/@Dist Set @iCounter = @BDown While @icounter < @Dist begin insert @TheList Select @iCounter, Dateadd(ss, @iCounter*@SPM, 0), DateAdd(ss, @iCounter*@SPM, @RStartTime) Set @iCounter = @iCounter + @BDown End ---Insert Last one if not an even mile IF Convert(int, 1000*@Dist) % Convert(int, 1000*@iCounter) <> 0 Begin insert @TheList values(@Dist, Dateadd(ss, @Dist*@SPM, 0), DateAdd(ss, @Dist*@SPM, @RStartTime)) End Select Convert(varchar(20), Dateadd(ss, @SPM, 0), 8 ) as MPM, Round(3600/@SPM, 3) as MPH Select Mile, Convert(varchar(20), RTime, 8 ) as Time, Convert(varchar(20), CrossingTime, 100) as 'SchedTime' from @TheList I’m currently training for the Des Moines Marathon on 10/18/09 and raising money for the American Cancer Society. The details, along with some fun stuff can be found here: |
||||
|
Copyright © 2012 SQL Feather and Quill - All Rights Reserved |
||||