Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sp_QuickieStore.sql: Moved capturing of _date_original variables outside of loop. #432

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 46 additions & 39 deletions sp_QuickieStore/sp_QuickieStore.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,50 @@ BEGIN
@query_text_search_original_value = @query_text_search;
END;

/*
We also need to capture original values here.
Doing it inside a loop over multiple databases
would break the UTC conversion.
*/
SELECT
@start_date_original =
ISNULL
(
@start_date,
DATEADD
(
DAY,
-7,
DATEDIFF
(
DAY,
'19000101',
SYSUTCDATETIME()
)
)
),
@end_date_original =
ISNULL
(
@end_date,
DATEADD
(
DAY,
1,
DATEADD
(
MINUTE,
0,
DATEDIFF
(
DAY,
'19000101',
SYSUTCDATETIME()
)
)
)
);

/*
This section is in a cursor whether we
hit one database, or multiple
Expand Down Expand Up @@ -1508,43 +1552,6 @@ SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;',
@rc = 0,
@em = @expert_mode,
@fo = @format_output,
@start_date_original =
ISNULL
(
@start_date,
DATEADD
(
DAY,
-7,
DATEDIFF
(
DAY,
'19000101',
SYSUTCDATETIME()
)
)
),
@end_date_original =
ISNULL
(
@end_date,
DATEADD
(
DAY,
1,
DATEADD
(
MINUTE,
0,
DATEDIFF
(
DAY,
'19000101',
SYSUTCDATETIME()
)
)
)
),
@utc_minutes_difference =
DATEDIFF
(
Expand Down Expand Up @@ -1647,7 +1654,7 @@ SELECT
(
MINUTE,
@utc_minutes_difference,
@start_date
@start_date_original
)
END,
@end_date =
Expand Down Expand Up @@ -1676,7 +1683,7 @@ SELECT
(
MINUTE,
@utc_minutes_difference,
@end_date
@end_date_original
)
END;

Expand Down