I am having the below SQL query:
DECLARE @MyVar datetime = '1/1/2010'
This normally returns '1/1/2010'.
What I need to do is have a list of dates, say:
Then I need to FOR EACH through the numbers and execute the SQL Query.
Something like (pseudocode):
List = 1/1/2010,2/1/2010,3/1/2010,4/1/2010,5/1/2010
For each x in List
DECLARE @MyVar datetime = x
So this would return:-
1/1/2010 2/1/2010 3/1/2010 4/1/2010 5/1/2010
I need this to return the data as one resultset, not the multiple resultsets, so I may want to use some sort of union at the end of the query, so every iteration of the loop unions onto the next.