View script-server-principals.sql
This file contains 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
DECLARE @principals TABLE ( | |
seq int IDENTITY(1, 1) NOT NULL, | |
principal_id int NOT NULL, | |
[sql] nvarchar(max) NOT NULL, | |
PRIMARY KEY CLUSTERED (seq) | |
); | |
--- Windows logins and groups: | |
INSERT INTO @principals (principal_id, [sql]) | |
SELECT sp.principal_id, |
View make-sa-database-owner.sql
This file contains 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
DECLARE @sql nvarchar(max)=N''; | |
SELECT @sql=@sql+N' | |
USE '+QUOTENAME(db.[name])+N'; | |
IF (USER_ID('+QUOTENAME(sp.[name], N'''')+N') IS NULL) | |
CREATE USER '+QUOTENAME(sp.[name])+N' FOR LOGIN '+QUOTENAME(sp.[name])+N'; | |
ALTER ROLE [db_owner] ADD MEMBER '+QUOTENAME(sp.[name])+N'; | |
View New-MastodonPost.ps1
This file contains 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
<# | |
To create an access token, | |
* go to settings -> Development | |
* Click "New Application" | |
* Enter a name | |
* Allow "write:statuses" | |
* Click Submit | |
* Click on the new application to review the keys | |
* The "Access token" is the one you need |
View New-PasswordLink.ps1
This file contains 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
<# | |
Generate a password pusher URL. | |
#> | |
$secretString = "Be vewy, vewy quiet. I'm hunting wabbits." | |
$maxDays = 1 # Number of days the link is valid | |
$maxCount = 1 # Maximum number of times the link can be used | |
$pwStrdCo = (Invoke-WebRequest ` | |
-Uri "https://pw.strd.co/generate" ` |
View dbo.Template_Split.sql
This file contains 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
/* | |
Copyright Daniel Hutmacher under Creative Commons 4.0 license with attribution. | |
http://creativecommons.org/licenses/by/4.0/ | |
Source: https://github.com/sqlsunday/sp_ctrl3 | |
DISCLAIMER: This script may not be suitable to run in a production | |
environment. I cannot assume any responsibility regarding | |
the accuracy of the output information, performance |
View Find primary key candidates.sql
This file contains 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
-- Source: https://sqlsunday.com/2017/02/21/finding-primary-key-candidates/ | |
IF (OBJECT_ID('dbo.FindPrimaryKey') IS NULL) | |
EXEC('CREATE PROCEDURE dbo.FindPrimaryKey AS --'); | |
GO | |
/* | |
This stored procedure is used to identify primary key candidates. | |
Copyright Daniel Hutmacher under Creative Commons 4.0 license with attribution. |
View Agent job visualization.sql
This file contains 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
--- Read more: https://sqlsunday.com/2016/11/17/visual-representation-of-sql-server-agent-jobs/ | |
/* | |
Copyright Daniel Hutmacher under Creative Commons 4.0 license with attribution. | |
http://creativecommons.org/licenses/by/4.0/ | |
Source: http://sqlsunday.com/downloads/ | |
DISCLAIMER: This script may not be suitable to run in a production |
View LoadTableBlobs.sql
This file contains 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
--- Read this first: https://sqlsunday.com/2016/06/16/copying-data-with-foreign-keys-and-identity-columns/ | |
IF (OBJECT_ID('dbo.LoadTableBlobs') IS NULL) EXEC('CREATE PROCEDURE dbo.LoadTableBlobs AS --') | |
GO | |
/* | |
Copyright Daniel Hutmacher under Creative Commons 4.0 license with attribution. | |
http://creativecommons.org/licenses/by/4.0/ | |
Source: http://sqlsunday.com/downloads/ |
View Decrypt T-SQL modules.sql
This file contains 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
-- More information: https://sqlsunday.com/2013/03/24/decrypting-sql-objects/ | |
SET NOCOUNT ON | |
DECLARE @owner sysname='dbo', @name sysname='sp_someprocedure'; | |
----------------------------------------------------------- | |
--- Declarations: | |
DECLARE @offset int=1; | |
DECLARE @datalength int; |
View Extract-WooCommerceOrders.ps1
This file contains 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
# Provided as-is, without any warranty, implied or express. | |
# General: | |
$file = "Precon-" + (Get-Date).toString("yyyyMMdd-HHmmss") + ".se" | |
$baseUri = "https://example.com/wp-json/wc/v3/" | |
# WooCommerce authentication: | |
$key = "cs_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | |
$secret = "cs_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | |
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $key, $secret))) |
NewerOlder