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 @StartDate date | |
declare @EndDate date | |
declare @OverallEndDate date | |
declare @PrintStart varchar(10) | |
declare @PrintEnd varchar(10) | |
-- Set the start date and overall end date | |
-- Set the end date to 7 days after the start date | |
set @OverallEndDate = '2018-12-31' | |
set @StartDate = '2018-01-01' |
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
/** | |
* The following are a few useful date formats in SQL Server | |
* These can be used for various types of output such as status | |
* or naming files. | |
*/ | |
select convert(varchar(10), getdate(), 120); /* YYYY-MM-dd */ | |
select convert(varchar(16), getdate(), 120); /* YYYY-MM-dd HH:mm */ | |
select convert(varchar(20), getdate(), 112); /* YYYYMMdd */ | |
select format(getdate(), 'yyyyMMdd_HHmm', 'en-US'); /* YYYYMMdd_HHmm */ |
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
rs.initiate( | |
{ | |
_id: "{{ group_names[0] }}", | |
members: [ | |
{% for h in groups[group_names[0] ]%} | |
{ _id: {{ loop.index }}, host : "{{ h }}": | |
{%if hostvars[inventory_hostname].group_names[0].startswith('shard') %} | |
{{ shard_port }} | |
{% else %} | |
{{ cfgserver_port }} |
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
# mongod.conf, Percona Server for MongoDB | |
# for documentation of all options, see: | |
# http://docs.mongodb.org/manual/reference/configuration-options/ | |
# Where and how to store data. | |
storage: | |
dbPath: /var/lib/mongodb | |
journal: | |
enabled: true | |
# engine: wiredTiger |
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
// The following MongoDB script displays all users and roles for all databases. | |
// Appropriate permissions are required to run this script | |
use admin | |
// Increase the number of documents returned by the find command | |
// Use either the legacy mongo shell version or Mongosh version | |
// Legacy Mongo Shell version | |
DBQuery.shellBatchSize = 300 | |
// Mongosh version |
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 Export-SqlReplicationArticles { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$ServerInstance, | |
[Parameter(Mandatory=$true)] | |
[string]$DatabaseName, | |
[Parameter(Mandatory=$true)] |
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 Get-DbaReplicationArticle { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$SqlInstance, | |
[Parameter(Mandatory=$true)] | |
[string]$Database | |
) | |
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
-- The following command will generate the | |
-- Statistics Rebuild command for all of the | |
-- statistics on a the targeted schema and table | |
select 'update statistics ' + sc.name + '.' + so.name + '(' + stat.name + ') with fullscan;' as Script | |
, stats_date(stat.object_id, stat.stats_id) as last_updated | |
, stuff(( | |
select ', ' + cols.name | |
from sys.stats_columns as statcols | |
join sys.columns as cols | |
on statcols.column_id = cols.column_id |
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
# Import SQL Server module | |
Import-Module "SQLPS" -DisableNameChecking | |
# Variables | |
$ServerName = "YourServerName" # Enter your server name here | |
$Server = New-Object Microsoft.SqlServer.Management.Smo.Server $ServerName | |
# Get the availability groups | |
$AvailabilityGroups = $Server.AvailabilityGroups |
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
-- A Quick query to view postgresql grant information | |
-- Work in progress | |
SELECT | |
'TABLE' AS object_type, | |
grantee, | |
table_schema, | |
table_name, | |
privilege_type | |
FROM | |
information_schema.role_table_grants |
OlderNewer