for /R %i in (*.jpg) do cjxl.exe --lossless_jpeg=1 "%i" "%~dpni.JXL"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select left(appdomain_name, 19) as appdomain_name, [state] | |
, sum(total_allocated_memory_kb) / 1024. AS total_allocated_memory_MB | |
, sum(survived_memory_kb) / 1024. as survived_memory_MB | |
from sys.dm_clr_appdomains | |
group by left(appdomain_name, 19), [state] | |
--select * from sys.dm_clr_properties | |
--select * from sys.dm_clr_appdomains | |
--select * from sys.dm_clr_loaded_assemblies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP PROCEDURE IF EXISTS dbo.SetDatabaseSingleUser | |
GO | |
CREATE PROCEDURE dbo.SetDatabaseSingleUser | |
@DatabaseName sysname | |
, @debug tinyint = 0 | |
AS | |
IF @debug = 1 PRINT FORMATMESSAGE('%s %s: stored procedure starting', convert(varchar(25), getdate(), 120), QUOTENAME(OBJECT_NAME(@@PROCID))); | |
IF @debug = 1 PRINT FORMATMESSAGE('%s %s: parameter @DatabaseName=''%s''', convert(varchar(25), getdate(), 120), QUOTENAME(OBJECT_NAME(@@PROCID)), @DatabaseName); | |
SET NOCOUNT ON; | |
SET XACT_ABORT ON; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$cred = Get-Credential; | |
Get-DbaRegisteredServer -Group "Monitored\SQLAuth" | % { | |
Write-Host "connecting to $($_.ServerName)"; | |
$srv = new-object Microsoft.sqlserver.management.smo.server $_.ServerName; | |
$srv.ConnectionContext.LoginSecure = $false; | |
$srv.ConnectionContext.Login = $Cred.UserName; | |
$srv.ConnectionContext.set_SecurePassword($cred.Password); | |
$srv.JobServer.Alerts | % { | |
if ($_.DelayBetweenResponses -eq 0) { $_.DelayBetweenResponses = 60; $_.Alter(); } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Show different ways to represent the duration of a time interval starting form elapsed milliseconds | |
-- adapted from https://stackoverflow.com/a/26347259 | |
DECLARE @x bigint = (24*60*60*1000)-2; -- milliseconds | |
SELECT | |
CONVERT(varchar, @x / 1000 / 86400) + ':' + CONVERT(varchar, DATEADD(ms, (@x % 86400) * 1000, 0), 108) AS [DD:HH:MM:SS] | |
, CONVERT(varchar, @x / 1000 / 86400) + ':' + CONVERT(varchar, DATEADD(ms, @x, 0), 114) AS [DD:HH:MM:SS.MS] | |
, CASE WHEN CONVERT(varchar, @x / 1000 / 86400) > 0 THEN CONVERT(varchar, @x / 1000 / 86400) + ':' ELSE '' END + CONVERT(varchar, DATEADD(ms, (@x % 86400) * 1000, 0), 108) AS [{DD:}HH:MM:SS] | |
, CASE WHEN CONVERT(varchar, @x / 1000 / 86400) > 0 THEN CONVERT(varchar, @x / 1000 / 86400) + ':' ELSE '' END + CONVERT(varchar, DATEADD(ms, @x, 0), 114) AS [{DD:}HH:MM:SS.MS] | |
, CONVERT(varchar, @x / 1000 / 86400) + ' day(s) ' + CONVERT(varchar, DATEADD(ms, (@x % 86400) * 1000, 0), 108) AS [DD day(s) HH:MM:SS] | |
, CONVERT(varchar, @x / 1000 / 86400) + ' day(s) ' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------- | |
-- search schema catalog for column names | |
-- example template showing how to execute for each database | |
------------------------------------------------------------------------------- | |
DECLARE @Databases TABLE (DatabaseName sysname primary key); | |
DECLARE @DatabaseName sysname; | |
DECLARE @sqlstmt_replaced nvarchar(max); | |
-- temp table to hold merged results instead of multiple results sets | |
DROP TABLE IF EXISTS #tmp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extract counters first with relog.exe .\myfile.blg -q > counters.txt | |
$currentPath = $PSScriptRoot # AzureDevOps, Powershell | |
if (!$currentPath) { $currentPath = Split-Path $pseditor.GetEditorContext().CurrentFile.Path -ErrorAction SilentlyContinue } # VSCode | |
if (!$currentPath) { $currentPath = Split-Path $psISE.CurrentFile.FullPath -ErrorAction SilentlyContinue } # PsISE | |
if ($currentPath) { Set-Location $currentPath } | |
#$Databases = ("databasename"); | |
$Databases = @(Get-Content (Join-Path $currentPath "databases.txt")); | |
$LinesRead = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE AdventureWorks2017; | |
GO | |
SELECT * FROM Person.Person; | |
BEGIN TRANSACTION; | |
WITH cte AS | |
( | |
SELECT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE AdventureWorks2017; | |
GO | |
SELECT | |
LastName | |
, CRYPT_GEN_RANDOM(4) AS crypt_gen_rand_value -- only available SQL Server >= 2012 | |
, CAST(NEWID() AS VARBINARY(4)) AS newid_value | |
, LEFT(CONVERT(nvarchar(128), HASHBYTES('SHA2_512', LastName), 2), 20) AS hashbytes_value | |
, LEFT(CONVERT(nvarchar(128), HASHBYTES('SHA2_512', CAST(LastName AS VARBINARY) + CRYPT_GEN_RANDOM(4)), 2), 20) AS hashbytes_crypt_gen_rand_append_value | |
, LEFT(CONVERT(nvarchar(128), HASHBYTES('SHA2_512', CAST(LastName AS VARBINARY) + CAST(NEWID() AS VARBINARY(4))), 2) , 20) AS hashbytes_newsid_append_value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH cte_sessions AS | |
( | |
SELECT | |
exs.session_id | |
, exs.database_id | |
, exs.last_request_start_time | |
, exs.last_request_end_time | |
, exs.memory_usage | |
, ssu.user_objects_alloc_page_count + | |
ssu.internal_objects_alloc_page_count AS tempdb_page_allocations |