Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Nelson SQLvariant

View GitHub Profile
@SQLvariant
SQLvariant / Query_DB2.ps1
Created Nov 20, 2020
Uploaded via PowerShell
View Query_DB2.ps1
$dbName="SAMPLE"
$server="not.my.localhost"
#Define connection string for the database
$cn = new-object system.data.OleDb.OleDbConnection("server=$($server);Provider=IBMDADB2;DSN=$($dbName);trusted_connection=true;");
#Define data set for first query
$ds = new-object "System.Data.DataSet" "ds"
#Define query to run
$q = "select * from hello_world"
# Define data object given the specific query and connection string
@SQLvariant
SQLvariant / Invoke-DaxQuery.Test.ps1
Last active Nov 11, 2020
PowerShell function to run a DAX query against a Power BI Repot / Analysis Services, and accompanying Pester test (which requires a separate .PBIX file that I haven't published yet)
View Invoke-DaxQuery.Test.ps1
Describe "Invoke-DaxQuery" {
Context "Invoke a DAX Query and test the result"{
# Run queries and compare them
$results = Invoke-DaxQuery -DAXQuery "EVALUATE ReportCatalogQuery"
# Test if the config was retrieved
It "Should verify the count is correct by comparing against a static number" {
@($results).Count | Should -Be 36
}
View RetrieveObject_Get-RsDeploymentConfig.ps1
Get-RsDeploymentConfig -RsProjectFile 'C:\Repos\GitHub\ReportingServicesTools\Tests\CatalogItems\testResources\TestProjects\SQLServerPerformanceDashboardReportingSolution\SQL Server Performance Dashboard\SQL Server Performance Dashboard.rptproj' -ConfigurationToUse Release
FullPath : Release
OverwriteDatasets : False
OverwriteDataSources : False
TargetReportFolder : SQL Server Performance Dashboard
TargetDatasetFolder : /Datasets
TargetDatasourceFolder : /Data Sources
TargetReportPartFolder : Report Parts
TargetServerURL : http://localhost/reportserver
@SQLvariant
SQLvariant / Build_SQLInstance_wStringCreds_andPortNumber.ps1
Last active Oct 15, 2020
Use Invoke-ExecuteNotebook to build a SQL-on-Linux instance in a Docker container, by calling Invoke-ExecuteNotebook to execute the Notebook, and passing in the sa_password & digits for the name/port number to the Notebook as a parameter.
View Build_SQLInstance_wStringCreds_andPortNumber.ps1
Invoke-ExecuteNotebook -InputNotebook .\SQL-on-Docker-with-PowerShell.ipynb -Parameters @{sa_password = 'Test9999'; SQLNumber = 97}
@SQLvariant
SQLvariant / Build_SQLInstance_wStringCreds.ps1
Created Sep 29, 2020
Use Invoke-ExecuteNotebook to build a SQL-on-Linux instance in a Docker container, by calling a Notebook to execute, and passing in the sa_password to the Notebook as a parameter.
View Build_SQLInstance_wStringCreds.ps1
Invoke-ExecuteNotebook -InputNotebook .\DockerDesktop-with-SQL-PowerShell-90.ipynb -Parameters @{sa_password = 'Test9999'}
@SQLvariant
SQLvariant / DockerDesktop-with-SQL-PowerShell-90.ipynb
Last active Oct 3, 2020
Create a SQL-on-Linux Docker Container with a Host Mount and Restore the AdventureWorks2016 Database
View DockerDesktop-with-SQL-PowerShell-90.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / Download_Notebook.ps1
Last active Oct 15, 2020
Example PowerShell Notebook to show you examples of what will happen when you use the ConvertTo-SQLNoteBook function.
View Download_Notebook.ps1
irm https://gist.githubusercontent.com/SQLvariant/5cbad3dd52093fbd053ec46769a0fc22/raw/1ecf6c292a6c0b9419af01d7360d373a2adff3cd/Using_ConvertTo-SQLNoteBook.ipynb -OutFile Using_ConvertTo-SQLNoteBook.ipynb
@SQLvariant
SQLvariant / SqlAssessment ChecksSQL.ipynb
Created Aug 18, 2020
PowerShell Notebook for working with the Get-SqlAssessmentItem & Invoke-SqlAssessment cmdlets from the SqlServer module.
View SqlAssessment ChecksSQL.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SQLvariant
SQLvariant / CellFindingVisitor.cs
Created Aug 11, 2020 — forked from rjmholt/CellFindingVisitor.cs
PowerShell AST visitor to break up a file by comments
View CellFindingVisitor.cs
using System;
using System.Collections.Generic;
using System.Management.Automation.Language;
public class ScriptExtent : IScriptExtent
{
private readonly IScriptPosition _start;
private readonly IScriptPosition _end;
@SQLvariant
SQLvariant / Download_Sample_SQL_Files.ps1
Created Aug 3, 2020
Central file to document & download all the various .SQL files we are testing against.
View Download_Sample_SQL_Files.ps1
<# Change this to the directory you want to download all these .SQL files into #>
cd "$home\Documents\GitHub\Hackathon2020\SQL-to-IPYNB\Sample SQL files"
<# Now go ahead and start downloading. #>
irm https://gist.githubusercontent.com/MsSQLGirl/799d3613c6b3aba58cb4decbb30da139/raw/433ffdcefcbc4db0e5f5c9b53e1e9bde139f885d/SQLSample_01_ServerProperties.sql > '.\SQLSample_01_ServerProperties.sql'
irm https://gist.githubusercontent.com/MsSQLGirl/799d3613c6b3aba58cb4decbb30da139/raw/433ffdcefcbc4db0e5f5c9b53e1e9bde139f885d/SQLSample_02_WWI.sql > '.\SQLSample_02_WWI.sql'
irm https://gist.githubusercontent.com/MsSQLGirl/799d3613c6b3aba58cb4decbb30da139/raw/433ffdcefcbc4db0e5f5c9b53e1e9bde139f885d/SQLSample_03_StringDynamics.sql > '.\SQLSample_03_StringDynamics.sql'
irm https://gist.githubusercontent.com/MsSQLGirl/799d3613c6b3aba58cb4decbb30da139/raw/433ffdcefcbc4db0e5f5c9b53e1e9bde139f885d/SQLSample_04_VariableBatchConundrum.sql > '.\SQLSample_04_VariableBatchConundrum.sql'
irm https://gist.githubusercontent.com/vic
You can’t perform that action at this time.