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
int value = conn.Query<int>(sql, args).Single(); | |
string value = conn.Query<string>(sql, args).Single(); | |
http://stackoverflow.com/questions/8050636/is-there-an-executescalar-in-dapper |
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
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a | |
; semicolon, such as this one, are comments. They are not executed. | |
; This script has a special filename and path because it is automatically | |
; launched when you run the program directly. Also, any text file whose | |
; name ends in .ahk is associated with the program, which means that it | |
; can be launched simply by double-clicking it. You can have as many .ahk | |
; files as you want, located in any folder. You can also run more than | |
; one .ahk file simultaneously and each will get its own tray icon. |
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
#How to install the Active Directory module for Powershell | |
#Source: https://blogs.technet.microsoft.com/ashleymcglone/2016/02/26/install-the-active-directory-powershell-module-on-windows-10/ | |
# Download the script referenced in the post and follow the directions |
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
$instanceName = "[db instance name goes here]" | |
$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName | |
$databasename = "[db name goes here]" | |
$timestamp = Get-Date -Format yyyyMMddHHmmss | |
$backupfolder = "[full path to backup folder]" | |
$backupfile = "$($databasename)_Full_$($timestamp).bak" | |
$fullBackupFile = Join-Path $backupfolder $backupfile | |
Backup-SqlDatabase ` |
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
-- SOURCE: http://stackoverflow.com/questions/6267273/how-to-restore-to-a-different-database-in-sql-server | |
-- Get the files, note the logical names of the .mdf and .ldf files | |
restore filelistonly from disk='E:\MSSQL\Backup\NewProjectExplorer\NewProjectExplorer_20170330.bak' | |
-- Restore and rename the backup | |
restore database [NewName] from disk = 'E:\MSSQL\Backup\NewProjectExplorer\NewProjectExplorer_20170330.bak' | |
with | |
move '[LogicalNameForMdf]' to 'E:\MSSQL\[NewName].mdf', | |
move '[LogicalNameForLdf]' to 'E:\MSSQL\[NewName]_log.ldf' |
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
-- convert all .xel files in a given folder to a single-column table | |
-- (alternatively specify an individual file explicitly) | |
select event_data = convert(xml, event_data) | |
into #eeTable | |
from sys.fn_xe_file_target_read_file(N'd:\killme\extended events\*.xel', null, null, null); | |
-- select from the table | |
select * from #eeTable | |
-- and click on a hyperlink value to see the structure of the xml |
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
function randomNumber(range) { | |
return Math.round(Math.random() * range); | |
} | |
// Usage: | |
console.log(`This is a random number from 0 to 20: ${randomNumber(20)}`); |
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
# Install SQL Server PowerShell module | |
# https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module | |
Install-Module -Name SqlServer | |
# Backing Up SQL Server Databases is Easier in PowerShell than T-SQL | |
# http://www.sqlservercentral.com/articles/PowerShell/151510/ | |
Get-SqlDatabase -ServerInstance [SERVERNAME]\SQLEXPRESS | | |
Where { $_.Name -eq '[DATABASENAME]' } | | |
Backup-SqlDatabase -BackupFile "c:\temp\[FILE PREFIX]$(Get-Date -UFormat %Y%m%d_%H%M).bak" -Script |
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
license: gpl-3.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
height: 540 |