Tenho a seguinte tabela com os seguintes dados:
DECLARE @MyActions TABLE (ActionId INT NOT NULL, ActionDate DATETIME NOT NULL)
INSERT INTO @MyActions VALUES (1, '2021-08-01 01:00:00')
INSERT INTO @MyActions VALUES (2, '2021-08-02 02:00:00')
INSERT INTO @MyActions VALUES (3, '2021-08-03 03:00:00')
INSERT INTO @MyActions VALUES (4, '2021-08-04 04:00:00')
Como faço para explodir cada ActionID em 10 registros adicionais (5 dias antes e 5 dias após a data do ActionID atual) sem usar a função de valor de tabela lenta?
ActionID = 1 deve explodir para 11 registros no total (sem o tempo), Ação 2 deve explodir para 11 registros no total (sem o tempo), etc
Conjunto de resultados explodido
1 2021-07-27 00:00:00.000
1 2021-07-28 00:00:00.000
1 2021-07-29 00:00:00.000
1 2021-07-30 00:00:00.000
1 2021-07-31 00:00:00.000
1 2021-08-01 00:00:00.000
1 2021-08-02 00:00:00.000
1 2021-08-03 00:00:00.000
1 2021-08-04 00:00:00.000
1 2021-08-05 00:00:00.000
1 2021-08-06 00:00:00.000
2 2021-07-28 00:00:00.000
2 2021-07-29 00:00:00.000
2 2021-07-30 00:00:00.000
2 2021-07-31 00:00:00.000
2 2021-08-01 00:00:00.000
2 2021-08-02 00:00:00.000
2 2021-08-03 00:00:00.000
2 2021-08-04 00:00:00.000
2 2021-08-05 00:00:00.000
2 2021-08-06 00:00:00.000
2 2021-08-07 00:00:00.000
3 2021-07-29 00:00:00.000
3 2021-07-30 00:00:00.000
3 2021-07-31 00:00:00.000
3 2021-08-01 00:00:00.000
3 2021-08-02 00:00:00.000
3 2021-08-03 00:00:00.000
3 2021-08-04 00:00:00.000
3 2021-08-05 00:00:00.000
3 2021-08-06 00:00:00.000
3 2021-08-07 00:00:00.000
3 2021-08-08 00:00:00.000
4 2021-07-30 00:00:00.000
4 2021-07-31 00:00:00.000
4 2021-08-01 00:00:00.000
4 2021-08-02 00:00:00.000
4 2021-08-03 00:00:00.000
4 2021-08-04 00:00:00.000
4 2021-08-05 00:00:00.000
4 2021-08-06 00:00:00.000
4 2021-08-07 00:00:00.000
4 2021-08-08 00:00:00.000
4 2021-08-09 00:00:00.000
Faça a junção cruzada de cada linha de origem com cada um dos 11 valores de dias de deslocamento, removendo a hora por meio de uma conversão até a data:
db<>demonstração de violino
Crie uma tabela de calendário e junte-se a ela.