sync
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"id": "e179aa64-7830-440b-a199-9c0a65750a8f",
|
||||||
|
"prefix": "find_query_plan_handle",
|
||||||
|
"description": "find a query plan from the cache and if needed drop it from the cache",
|
||||||
|
"body": "DECLARE @SearchForSql AS NVARCHAR(MAX) = N'TEXT_TO_FIND';\r\n\r\nSELECT usecounts,\r\n cacheobjtype,\r\n objtype,\r\n text,\r\n query_plan,\r\n [plan_handle]\r\n FROM sys.dm_exec_cached_plans\r\n CROSS APPLY sys.dm_exec_sql_text(plan_handle)\r\n CROSS APPLY sys.dm_exec_query_plan(plan_handle)\r\n WHERE text LIKE CONCAT('%', @SearchForSql, '%')\r\n AND text NOT LIKE '%-- Self Reference Marker --%';\r\n\r\n--DBCC FREEPROCCACHE (plan_handle_id_goes_here)"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"id": "59cdebdd-b515-4da4-b9f2-b5a552d5d736",
|
||||||
|
"prefix": "free_disk_space",
|
||||||
|
"description": "list disk usage and free space where db files are present",
|
||||||
|
"body": "--free disk space\r\nselect distinct\r\nconvert(varchar(512), b.volume_mount_point) as [volume_mount_point]\r\n, convert(varchar(512), b.logical_volume_name) as [logical_volume_name]\r\n, convert(decimal(18,1), round(((convert(float, b.available_bytes) / convert(float, b.total_bytes)) * 100),1)) as [percent_free]\r\n, convert(bigint, round(((b.available_bytes / 1024.0)/1024.0),0)) as [free_mb]\r\n, convert(bigint, round(((b.total_bytes / 1024.0)/1024.0),0)) as [total_mb]\r\n, convert(bigint, round((((b.total_bytes - b.available_bytes) / 1024.0)/1024.0),0)) as [used_mb]\r\n, CURRENT_TIMESTAMP AS now\r\n,REPLACE(@@SERVERNAME ,'\\apssql','')AS srvName\r\nfrom sys.master_files as [a]\r\nCROSS APPLY sys.dm_os_volume_stats(a.database_id, a.[file_id]) as [b]\r\nORDER BY [percent_free] ASC \r\n"
|
||||||
|
}
|
||||||
6
percent-59cf80eb-b43b-4e5a-9e33-3dbcc1102c6c.json
Normal file
6
percent-59cf80eb-b43b-4e5a-9e33-3dbcc1102c6c.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"id": "59cf80eb-b43b-4e5a-9e33-3dbcc1102c6c",
|
||||||
|
"prefix": "percent",
|
||||||
|
"description": "% of operation (BKP, RESTORE, COMPACT)",
|
||||||
|
"body": "SELECT [r].[session_id],\r\n [r].[command],\r\n CONVERT(NUMERIC(6, 2), [r].[percent_complete]) AS [Percent Complete],\r\n CONVERT(VARCHAR(20), DATEADD(ms, [r].[estimated_completion_time], GETDATE()), 20) AS [ETA Completion Time],\r\n CONVERT(NUMERIC(10, 2), [r].[total_elapsed_time] / 1000.0 / 60.0) AS [Elapsed Min],\r\n CONVERT(NUMERIC(10, 2), [r].[estimated_completion_time] / 1000.0 / 60.0) AS [ETA Min],\r\n CONVERT(NUMERIC(10, 2), [r].[estimated_completion_time] / 1000.0 / 60.0 / 60.0) AS [ETA Hours],\r\n CONVERT(\r\n VARCHAR(1000),\r\n ( SELECT SUBSTRING(\r\n text,\r\n r.statement_start_offset / 2,\r\n CASE\r\n WHEN r.statement_end_offset = -1 THEN 1000\r\n ELSE (r.statement_end_offset - r.statement_start_offset) / 2 END)\r\n FROM sys.dm_exec_sql_text(sql_handle) )) AS [SQL]\r\n FROM sys.dm_exec_requests r\r\nWHERE [r].[command] IN ( 'RESTORE DATABASE', 'BACKUP DATABASE', 'DbccFilesCompact', 'DbccSpaceReclaim' );\r\n\r\n"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"id": "3a792d1a-98ee-4d0e-98f7-c44d4b158772",
|
||||||
|
"prefix": "session_options",
|
||||||
|
"description": "show current session options",
|
||||||
|
"body": "with OPTION_VALUES as (\r\nselect\r\noptionValues.id,\r\noptionValues.name,\r\noptionValues.description,\r\nrow_number() over (partition by 1 order by id) as bitNum\r\nfrom (values\r\n(1, 'DISABLE_DEF_CNST_CHK', 'Controls interim or deferred constraint checking.'),\r\n(2, 'IMPLICIT_TRANSACTIONS', 'For dblib network library connections, controls whether a transaction is started implicitly when a statement is executed. The IMPLICIT_TRANSACTIONS setting has no effect on ODBC or OLEDB connections.'),\r\n(4, 'CURSOR_CLOSE_ON_COMMIT', 'Controls behavior of cursors after a commit operation has been performed.'),\r\n(8, 'ANSI_WARNINGS', 'Controls truncation and NULL in aggregate warnings.'),\r\n(16, 'ANSI_PADDING', 'Controls padding of fixed-length variables.'),\r\n(32, 'ANSI_NULLS', 'Controls NULL handling when using equality operators.'),\r\n(64, 'ARITHABORT', 'Terminates a query when an overflow or divide-by-zero error occurs during query execution.'),\r\n(128, 'ARITHIGNORE', 'Returns NULL when an overflow or divide-by-zero error occurs during a query.'),\r\n(256, 'QUOTED_IDENTIFIER', 'Differentiates between single and double quotation marks when evaluating an expression.'),\r\n(512, 'NOCOUNT', 'Turns off the message returned at the end of each statement that states how many rows were affected.'),\r\n(1024, 'ANSI_NULL_DFLT_ON', 'Alters the session'+char(39)+'s behavior to use ANSI compatibility for nullability. New columns defined without explicit nullability are defined to allow nulls.'),\r\n(2048, 'ANSI_NULL_DFLT_OFF', 'Alters the session'+char(39)+'s behavior not to use ANSI compatibility for nullability. New columns defined without explicit nullability do not allow nulls.'),\r\n(4096, 'CONCAT_NULL_YIELDS_NULL', 'Returns NULL when concatenating a NULL value with a string.'),\r\n(8192, 'NUMERIC_ROUNDABORT', 'Generates an error when a loss of precision occurs in an expression.'),\r\n(16384, 'XACT_ABORT', 'Rolls back a transaction if a Transact-SQL statement raises a run-time error.')\r\n) as optionValues(id, name, description)\r\n)\r\nselect *, case when (@@options & id) = id then 1 else 0 end as setting\r\nfrom OPTION_VALUES\r\nORDER BY [setting];"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user