Using: SQL Server 2008 R2
I’d like to write a query that will select (ordered, in a single column) every second in a day in datetime format.
Ex.
2012-02-02 00:00:00
2012-02-02 00:00:01
2012-02-02 00:00:02
2012-02-02 00:00:03
2012-02-02 00:00:04
...
2012-02-02 23:59:58
2012-02-02 23:59:59
Yeah, seriously.
I can make a numbers table if need be, which might be helpful if I can convert integer values to datetime.
Thanks in advance.
This assumes a numbers table with values up to 86,400… the number of seconds in a day.
To illustrate, I create a numbers table here… but you should do this ahead of time.