I have a SQL Server select
statement which is inserting data in a created table.
Right now I have to define all parameters and run the statement for each of them. To be more efficient I would like to run the statement like multiple times for a row of some consecutive days, e.g. for all days between 2013-31-12
and 2014-02-19
.
At the end I want to have the resulting data in one table with different timestamps in the defined timestamp
column (let's say the defined variable).
Right now I working with this:
DECLARE @historicalDate DATETIME
SELECT @historicalDate = '2013-31-12'#
SELECT * ....
rest...
into #data
I know how to do it in C or MATLAB. I would just use a for loop and define a running variable to run the statement and store it in a table.
But how to handle in SQL Server?