Skip to content

Instantly share code, notes, and snippets.

View RichieBzzzt's full-sized avatar
🦆
Sirfetch'd

Richie Lee RichieBzzzt

🦆
Sirfetch'd
View GitHub Profile
function publish-SsasDb {
[CmdletBinding()]
param(
[Parameter(Position = 0, mandatory = $true)]
[string] $TargetSsasSvr,
[Parameter(Position = 1, mandatory = $true)]
[string] $sourceDb,
[Parameter()]
[switch] $runscript,
[Parameter()]
<Cancel xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<ConnectionID>...</ConnectionID>
<SessionID>...</SessionID>
<SPID>...</SPID>
<CancelAssociated>true/false</CancelAssociated>
</Cancel>
SELECT * FROM $SYSTEM.DISCOVER_CONNECTIONS
SELECT * FROM $SYSTEM.DISCOVER_SESSIONS
SELECT * FROM $SYSTEM.DISCOVER_COMMANDS
SELECT SESSION_SPID, COMMAND_CPU_TIME_MS, COMMAND_ELAPSED_TIME_MS, COMMAND_READ_KB, COMMAND_WRITE_KB, COMMAND_TEXT FROM $system.DISCOVER_COMMANDS WHERE COMMAND_ELAPSED_TIME_MS > 0 ORDER BY COMMAND_CPU_TIME_MS DESC
select TOP 25 SESSION_SPID, SESSION_USER_NAME,SESSION_IDLE_TIME_MS, SESSION_USED_MEMORY, SESSION_LAST_COMMAND, SESSION_LAST_COMMAND_END_TIME, SESSION_ID from $system.DISCOVER_SESSIONS WHERE SESSION_STATUS = 0 ORDER BY SESSION_IDLE_TIME_MS DESC
SELECT SESSION_SPID,SESSION_USER_NAME,SESSION_START_TIME, SESSION_ELAPSED_TIME_MS, SESSION_CPU_TIME_MS,SESSION_ID FROM $SYSTEM.DISCOVER_SESSIONS WHERE SESSION_STATUS = 2 ORDER BY SESSION_USER_NAME DESC
"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /Action:Import /SourceFile:"C:\Users\Richie\Downloads\WideWorldImportersDW-Standard.bacpac" /TargetConnectionString:"Server=tcp:{yourdb}.database.windows.net,1433;Initial Catalog=sioEverestDb;Persist Security Info=False;User ID={uid};Password={pword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /Action:Import /SourceFile:"C:\Users\Richie\Downloads\WideWorldImporters-Standard.bacpac" /TargetConnectionString:"Server=tcp:{yourdb}.database.windows.net,1433;Initial Catalog=sioEverestDb;Persist Security Info=False;User ID={uid};Password={pword};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
{
"integrationServicesCatalog": {
"ssisFolderName": "",
"ssisEnvironmentName": "",
"ssisProjectName": "",
"ssisEnvironmentDescription": ""
},
"ssisEnvironmentVariable": [
{
"variableName": "",
cls
Import-Module "C:\Users\Richie\Source\Repos\AssistDeploy" -Force
$svr = "Server=.\sixteen;Integrated Security=True"
$ssisdb = Connect-SsisdbSql -sqlConnectionString $svr
$projectName = "Daily ETL"
$environmentname = "nevis"
$foldername = "ssis_guy"
$desc = "sample ETL process that only uses databases"
$myJsonObject = Get-SsisAsJson -sqlConnection $ssisdb -ssisEnvironment $environmentname -ssisFolder $foldername -ssisProject $projectName -ssisEnvironmentDescription $desc
$myJsonObject | out-file "C:\Users\Richie\Source\Repos\AssistDeploy\Daily_ETL.json"
{
"IntegrationServicesCatalog": {
"ssisEnvironmentName": "nevis",
"ssisProjectName": "Daily ETL",
"ssisFolderName": "ssis_guy",
"ssisEnvironmentDescription": "sample ETL process that only uses databases"
},
"SsisEnvironmentVariable": [
{
"isSensitive": false,
cls
Import-Module "C:\Users\Richie\Source\Repos\AssistDeploy" -Force
$thisSsisPublishFilePath = "C:\Users\Richie\Source\Repos\sql-server-samples\samples\databases\wide-world-importers\wwi-ssis\wwi-ssis\bin\Development\DailyETL.json"
$thisIspacToDeploy = "C:\Users\Richie\Source\Repos\sql-server-samples\samples\databases\wide-world-importers\wwi-ssis\wwi-ssis\bin\Development\Daily ETL.ispac"
$svr = "Server=siossiseverest.database.windows.net;User ID=;Password=;Initial Catalog=SSISDB"
$myJsonPublishProfile = Import-Json -jsonPath $thisSsisPublishFilePath -ispacPath $thisIspacToDeploy -localVariables
$ssisdb = Connect-SsisdbSql -sqlConnectionString $svr
Publish-SsisFolder -jsonPsCustomObject $myJsonPublishProfile -sqlConnection $ssisdb
Publish-SsisEnvironment -jsonPsCustomObject $myJsonPublishProfile -sqlConnection $ssisdb
Publish-SsisIspac -jsonPsCustomObject $myJsonPublishProfile -sqlConnection $ssisdb -ispacToDeploy $thisIspacToDeploy
;
WITH cte
AS (
SELECT referenced_variable_name
FROM CATALOG.object_parameters p
WHERE project_id = (
SELECT project_id
FROM CATALOG.projects proj
WHERE proj.NAME = @1
AND proj.folder_id = (