I have the following SQL query:
DECLARE @MyVar datetime = '1/1/2010' SELECT @MyVar
This naturally returns '1/1/2010'.
What I want to do is a list of dates, let's say:
1/1/2010 2/1/2010 3/1/2010 4/1/2010 5/1/2010
Then I want to EVERYONE through numbers and run an SQL query.
Something like (pseudo code):
List = 1/1/2010,2/1/2010,3/1/2010,4/1/2010,5/1/2010 For each x in List do DECLARE @MyVar datetime = x SELECT @MyVar
So this will return: -
1/1/2010 2/1/2010 3/1/2010 4/1/2010 5/1/2010
I want this to return data as one result set, not multiple result sets, so I might need to use some kind of union at the end of the query, so every loop loop iteration to the next.
change
I have a big request that accepts the "up to date" parameter, I need to run it 24 times, each time with specific dates that I need to provide (these dates will be dynamic) I want to avoid repeating my request 24 times with the union of all joining to them, as if I need to go back and add additional columns, it will be very time consuming.
sql sql-server tsql
JsonStatham Apr 24 2018-12-12T00: 00Z
source share