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
-- From this article: https://logicalread.com/troubleshoot-high-cpu-sql-server-pd01/#.WW_hjtPytuY | |
-- Show CPU Utilization by SQL Server, system idle time and other processes | |
DECLARE @ms_ticks_now BIGINT | |
SELECT @ms_ticks_now = ms_ticks | |
FROM sys.dm_os_sys_info; | |
SELECT TOP 15 record_id | |
,dateadd(ms, - 1 * (@ms_ticks_now - [timestamp]), GetDate()) AS EventTime | |
,SQLProcessUtilizationPercent |
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 | |
* | |
FROM | |
INFORMATION_SCHEMA.ROUTINES | |
WHERE | |
ROUTINE_DEFINITION LIKE '%My Text%' | |
ORDER BY ROUTINE_NAME; |
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
# This is something that I always forget and had a surprisingly hard time finding (or better yet, understanding). Here's the | |
# scenario: a colleague creates a new kubernetes cluster, named" cluster-foo.example.com". You want to look at it (for | |
# troubleshooting, updating the deployment, whatever). To get your kubectl installation to "see" the new cluster, take the | |
# following steps: | |
# ASSUMPTION: You have pointed kops to some location where the cluster configurations are stored | |
# (I have this in my ~/.bash_profile): | |
export KOPS_STATE_STORE=s3://example-state-store | |
# Use kops to get the list of clusters |
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
# Occasionally I want to see the application properties that are pulled down from the Spring Cloud Config service that provides | |
# content to our Spring Boot apps. Since I seem to have to re-discover this every time, I figured I'd write it down to help me | |
# remember. | |
# | |
# Additional docs can be found here: https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html | |
# To see the output in YML format | |
curl -u {the user name}:{the user password} http://{the domain:port}/{the application name}-{the spring profile name}.yml | |
# For example: |
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
// jsfiddle: https://jsfiddle.net/Lkxtryvp/1/ | |
var myAwesomeLoop = function(x) { | |
// This is the magic sauce right here - you're creating a unit of work that will be done at some | |
// point in the future. We're not exactly sure when, but the deferred object will notify us when | |
// it's done (by calling "resolve()" or "reject()" on itself). | |
var deferred = $.Deferred(); | |
// We'll create a simple loop to concatenate some values together. This simulates where the | |
// actual, for-real work would be done (e.g. an AJAX request, some sort of long-running calculation, etc) |
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
-- from here: https://gallery.technet.microsoft.com/scriptcenter/Rebuild-and-Reorganize-7ff5624e | |
DECLARE | |
@fragPercentThreshold decimal(11,2), | |
@schemaName nvarchar(128); | |
-- Determine maximum fragmentation threshold and the schema to operate against | |
SET @fragPercentThreshold = 5.0; | |
SET @schemaName = N'dbo'; |
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
DECLARE | |
@backupMsg varchar(max), | |
@backupPath varchar(max), | |
@backupCommand varchar(max), | |
@dbName varchar(max); | |
SELECT | |
@backupMsg = 'Full backup', | |
@backupPath = 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Backup\'; |
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
-- Second answer from here: https://stackoverflow.com/questions/14704105/search-text-in-stored-procedure-in-sql-server | |
SELECT | |
name, | |
SCHEMA_NAME(schema_id) AS [schema] | |
FROM | |
sys.procedures | |
WHERE | |
OBJECT_DEFINITION(object_id) LIKE '%whatever text you are looking for%'; |
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
-- Based on answer from here: | |
-- https://stackoverflow.com/questions/483193/how-can-i-list-all-foreign-keys-referencing-a-given-table-in-sql-server | |
SELECT | |
child.name AS child_table, | |
fk.constraint_column_id AS fk_part_no, | |
c.name AS foreign_key_column | |
FROM | |
sys.foreign_key_columns AS fk | |
JOIN | |
sys.tables child |
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
/// <summary> | |
/// A class for rolling back database transactions after the test has completed. | |
/// </summary> | |
[TestClass] | |
public abstract class TransactionRollbackIntegrationTestBase | |
{ | |
private TransactionScope transactionScope; | |
/// <summary> | |
/// Create the transaction scope to enforce creating a new transaction prior to the test executing. |