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
$NewLineQuery = 'SELECT Notes FROM dbo.NewLineNotes' | |
$InvSQLParams = @{ | |
ServerInstance = '0738-5CG140G7T\SQLSERVER2K16' | |
Database = 'Pantheon' | |
Query = $NewLineQuery | |
} | |
Invoke-Sqlcmd @InvSQLParams | | |
Select-Object -Property Notes | |
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
USE Pantheon; | |
GO | |
DROP TABLE IF EXISTS dbo.CreateThenAlter; | |
CREATE TABLE dbo.CreateThenAlter | |
( | |
RBAR char(10) | |
); | |
GO | |
ALTER TABLE dbo.CreateThenAlter ADD CONSTRAINT CHK_CreateThenAlter_RBAR CHECK (RBAR IN ('good', 'bad')); | |
ALTER TABLE dbo.CreateThenAlter ADD CONSTRAINT DF_CreateThenAlter_RBAR DEFAULT ('good') FOR RBAR; |
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
DROP TABLE IF EXISTS dbo.AllInLine; | |
CREATE TABLE dbo.AllInLine | |
( | |
CheckyMcCheckFace char(10) | |
CONSTRAINT CHK_AllInLine_CheckyMcCheckFace CHECK (CheckyMcCheckFace IN ('good', 'bad')) | |
CONSTRAINT DF_AllInLine_CheckyMcCheckFace DEFAULT ('good') | |
); |
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
$NewLineQuery = 'SELECT Notes FROM dbo.NewLineNotes' | |
$InvSQLParams = @{ | |
ServerInstance = '0738-5CG140G7T\SQLSERVER2K16' | |
Database = 'Pantheon' | |
Query = $NewLineQuery | |
} | |
Invoke-Sqlcmd @InvSQLParams | | |
Select-Object -Property Notes | |
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
#... get some results to work with... | |
$sqlcmdParams = @{ | |
ServerInstance = 'localhost\SQLSERVER2K16' | |
Database = 'master' | |
Query = @' | |
SELECT TOP(10) | |
name | |
FROM dbo.spt_values | |
WHERE name IS NOT NULL | |
AND LEN(name) != 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
Function Get-BackupFilesSizes { | |
$Bak = $Diff = $Trn = 0; | |
$Bak = (Get-ChildItem -File | | |
Where-Object { $_.Extension -eq '.bak' } | | |
Measure-Object -Property Length -Sum).Sum; | |
$Diff = (Get-ChildItem -File | | |
Where-Object { $_.Extension -eq '.diff' } | | |
Measure-Object -Property Length -Sum).Sum; | |
$Trn = (Get-ChildItem -File | |
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 Import-Excel ($FolderPath, $XlsxFile, $Server, $Database, $Table) { | |
# Create an Excel workbook... | |
$Excel = New-Object -ComObject Excel.Application; | |
$Workbook = $Excel.WorkBooks.Open((Join-Path -Path (Convert-Path -Path $FolderPath) -ChildPath $XlsxFile)); | |
$WorkSheet = $Workbook.WorkSheets.Item(1); # Thankfully only 1 sheet so this doesn't need to change... | |
$StartRow = 2; # ...ignore headers... | |
# Insert into a System.Data.DataTable... | |
$DataTable = New-Object -TypeName System.Data.DataTable; | |
$null = $DataTable.Columns.Add('DiscId', 'System.Int32'); |
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
CREATE TABLE dbo.DiscCharacters ( | |
DiscId int IDENTITY(1, 1) NOT NULL, | |
Person varchar(50) NULL, | |
Job varchar(75) NULL, | |
Notes varchar(300) NULL | |
); | |
GO |
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
CREATE TABLE dbo.RunningTotals ( | |
SpentDate date NOT NULL, | |
SpentAmount smallmoney NOT NULL | |
); | |
GO | |
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
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (DATEADD(DAY, -1, GETDATE()), 50.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (DATEADD(DAY, -1, GETDATE()), 50.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (DATEADD(DAY, -1, GETDATE()), -75.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (DATEADD(DAY, -1, GETDATE()), 50.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (GETDATE(), 100.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (GETDATE(), 100.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (GETDATE(), -150.00); | |
INSERT INTO dbo.RunningTotals (SpentDate, SpentAmount) VALUES (GETDATE(), 100.00); |