sync
This commit is contained in:
@@ -2,5 +2,5 @@
|
|||||||
"id": "ca9ed7a3-6fb0-4d39-b918-887951161076",
|
"id": "ca9ed7a3-6fb0-4d39-b918-887951161076",
|
||||||
"prefix": "cal",
|
"prefix": "cal",
|
||||||
"description": "create a calendar #cal table",
|
"description": "create a calendar #cal table",
|
||||||
"body": "--#region create calendar\r\nDECLARE @nb TABLE( val INT);\r\nINSERT INTO @nb(val)\r\nSELECT a=0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9;\r\n\r\nIF (SELECT OBJECT_ID('tempdb..#cal'))IS NOT NULL BEGIN\r\n\tDROP TABLE #cal;\r\nEND; \r\n\r\nSELECT * \r\nINTO #cal\r\nFROM (\r\n\tSELECT \r\n\t\tdtm=DATEADD(\r\n\t\t\tDAY\r\n\t\t\t, DATEDIFF(\r\n\t\t\t\tDAY\r\n\t\t\t\t, 0\r\n\t\t\t\t, DATEADD(\r\n\t\t\t\t\tDAY\r\n\t\t\t\t\t, ROW_NUMBER()OVER(ORDER BY a.val) * -1\r\n\t\t\t\t\t, CURRENT_TIMESTAMP\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\t, 1\r\n\t\t)\r\n\tFROM @nb a\r\n\t\tCROSS JOIN @nb b\r\n\t\tCROSS JOIN @nb c\r\n\t\tCROSS JOIN @nb d\r\n)x\r\nWHERE 1=1\r\nAND x.dtm BETWEEN @dtmFrom AND @dtmTo;\r\n--#endregion\r\n"
|
"body": "DECLARE @dtmFrom DATETIME, @dtmTo DATETIME;\r\nSELECT @dtmFrom = '20100812', @dtmTo=CURRENT_TIMESTAMP\r\n\r\n--#region create calendar\r\nDECLARE @nb TABLE( val INT);\r\nINSERT INTO @nb(val)\r\nSELECT a=0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9;\r\n\r\nIF (SELECT OBJECT_ID('tempdb..#cal'))IS NOT NULL BEGIN\r\n\tDROP TABLE #cal;\r\nEND; \r\n\r\nSELECT \r\n --+1 to take the current day, must be reflected in the TOP subquery\r\n DATEADD(DAY, (x.[nbr] * -1) + 1, CURRENT_TIMESTAMP) AS dt\r\nINTO #cal\r\nFROM(\r\n SELECT * \r\n FROM (\r\n --the TOP limits the calendar to the specified days. +1 to compensate the current day in DATEADD()\r\n SELECT TOP (DATEDIFF(DAY, @dtmFrom, @dtmTo)+1)\r\n ROW_NUMBER()OVER(ORDER BY a.val) AS nbr\r\n FROM @nb a\r\n CROSS JOIN @nb b\r\n CROSS JOIN @nb c\r\n CROSS JOIN @nb d\r\n CROSS JOIN @nb e\r\n CROSS JOIN @nb f\r\n ORDER BY a.[val]\r\n )tally\r\n)x\r\n--#endregion\r\n\r\nSELECT MIN([c].[dt]), MAX([c].[dt])\r\nFROM [#cal] c"
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,11 @@
|
|||||||
"id": "f1c69117-2ba6-46d4-a3b6-ef957ac692fb",
|
"id": "f1c69117-2ba6-46d4-a3b6-ef957ac692fb",
|
||||||
"prefix": "reg",
|
"prefix": "reg",
|
||||||
"description": "",
|
"description": "",
|
||||||
"body": "--#region $CURSOR$\r\n--#endregion"
|
"body": "--#region $name$\r\n--#endregion $name$",
|
||||||
|
"placeholders": [
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"defaultValue": null
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
"id": "28ccb2a9-263a-46db-92e8-27d58971f114",
|
"id": "28ccb2a9-263a-46db-92e8-27d58971f114",
|
||||||
"prefix": "version",
|
"prefix": "version",
|
||||||
"description": "get tripaharm version",
|
"description": "get tripaharm version",
|
||||||
"body": "SELECT ActivePos_write.upd.DatabaseVersion()"
|
"body": "--pharma\r\nSELECT ActivePos_write.upd.DatabaseVersion()\r\n\r\n--central\r\nSELECT TOP 3 * \r\nFROM arizona.dbo.APS_version_history h\r\nWHERE [h].[APSVH_program_name]='Arizona'\r\nAND [h].[APSVH_program_version] IS NOT NULL \r\nORDER BY [APSVH_APS_TS] DESC "
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"id": "339f494d-8194-4fa6-b2b2-7133ecf49655",
|
"id": "339f494d-8194-4fa6-b2b2-7133ecf49655",
|
||||||
"prefix": "wac",
|
"prefix": "wac_old",
|
||||||
"description": "call sp_whoIsActive",
|
"description": "call sp_whoIsActive",
|
||||||
"body": "EXEC hciTools.dbo.sp_whoisactive\r\n @get_additional_info=0,@get_task_info=1, @output_column_list='[percent_complete][status][database_name][dd%][session_id][blocking_session_id][blocked_session_count][sql_text][sql_command][query_plan][login_name][wait_info][host_name][tasks][tran_log%][cpu%][temp%][block%][reads%][writes%][context%][physical%][locks][%]', @format_output=1\r\n ,@get_plans=0\r\n ,@get_outer_command=1\r\n ,@get_locks = 0\r\n ,@find_block_leaders = 1\t\r\n ,@sort_order = '[blocked_session_count] DESC,[session_id] ASC, [dd hh:mm:ss.mss] DESC';\r\n"
|
"body": "EXEC hciTools.dbo.sp_whoisactive\r\n @get_additional_info=0,@get_task_info=1, @output_column_list='[percent_complete][status][database_name][dd%][session_id][blocking_session_id][blocked_session_count][sql_text][sql_command][query_plan][login_name][wait_info][host_name][tasks][tran_log%][cpu%][temp%][block%][reads%][writes%][context%][physical%][locks][%]', @format_output=1\r\n ,@get_plans=0\r\n ,@get_outer_command=1\r\n ,@get_locks = 0\r\n ,@find_block_leaders = 1\t\r\n ,@sort_order = '[blocked_session_count] DESC,[session_id] ASC, [dd hh:mm:ss.mss] DESC';\r\n"
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"id": "f07d5721-90d8-4dfe-832f-2753f51b23bf",
|
|
||||||
"prefix": "wacd",
|
|
||||||
"description": "drop master.dbo.sp_whoisactive",
|
|
||||||
"body": "use master\r\nIF OBJECT_ID('master.dbo.sp_whoisactive') IS NOT NULL \r\n\tDROP PROCEDURE dbo.sp_whoisactive;"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user