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
license: mit | |
height: 700 |
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
license: gpl-3.0 |
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
license: gpl-3.0 |
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
height: 540 |
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
license: gpl-3.0 |
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
# 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 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 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 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 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 ` |
NewerOlder