This file contains hidden or 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-Module sqlserver | |
$serverName = "localhost" | |
$ExportFolder = "C:\temp\$serverName" | |
$databaseName = "AdventureWorks" | |
$tablesToExport = 'Person.Address','Person.AddressType','Person.BusinessEntity','Person.BusinessEntityAddress','Person.BusinessEntityContact','Person.ContactType','Person.CountryRegion','Person.EmailAddress','Person.Password','Person.Person','Person.PersonPhone','Person.PhoneNumberType','Person.StateProvince' | |
New-item -ItemType Directory -Path $ExportFolder -Force | |
foreach ($table in $tablesToExport) { |
This file contains hidden or 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
-- Description: Turns a query into a formatted HTML table. Useful for emails. | |
-- Any ORDER BY clause needs to be passed in the separate ORDER BY parameter. | |
-- Adapted and added code to format the code | |
-- ============================================= | |
CREATE OR ALTER PROC ##QueryToHtmlTable | |
( | |
@query nvarchar(MAX), --A query to turn into HTML format. It should not include an ORDER BY clause. | |
@orderBy nvarchar(MAX) = NULL, --An optional ORDER BY clause. It should contain the words 'ORDER BY'. | |
@html nvarchar(MAX) = NULL OUTPUT --The HTML output of the procedure. | |
) |
This file contains hidden or 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
/* Adapted from ChilledSql.com */ | |
/* https://www.chilledsql.com/welcome/tip_category_dateandtime/tip_detail_dateandtime_createmastercalendartable */ | |
/* Update the Start/End dates as appropriate for your needs */ | |
/* This is done after all creates */ | |
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED | |
SET NOCOUNT ON | |
SET ANSI_WARNINGS OFF | |
SET ARITHABORT OFF |
This file contains hidden or 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
# requires gtts | |
# requires pydub | |
# requires ffmpeg to be installed on the system | |
from gtts import gTTS | |
from pydub import AudioSegment | |
import os | |
def generate_word_audio(word, output_folder='audio'): | |
if not os.path.exists(output_folder): |
This file contains hidden or 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
<# | |
Code Type: Function | |
Description: Restore the missing Package(*.msi)/Patches(*.msp) files from another remote source (machine or folder). | |
Author: Ahmad Gad | |
Contact Email: [email protected], [email protected] | |
WebSite: http://ahmad.jempress.com | |
Created On: 21/09/2016 | |
Updated On: 11/03/2017 | |
Title: Restore-InstallerFiles | |
Minimum PowerShell Version: 2.0 |
This file contains hidden or 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 all db principals and their roles for Azure SQL */ | |
SELECT | |
@@ServerName as ServerName, | |
DB_NAME() as DatabaseName, | |
pr.name AS PrincipalName, | |
pr.type_desc AS PrincipalType, | |
r.name AS RoleName, | |
dp.state_desc AS RoleState, | |
NULL as PermissionName, | |
NULL as PermissionState, |
This file contains hidden or 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-module az.sql | |
import-module az.resources | |
import-module importexcel | |
# Update-AzConfig -DisplayBreakingChangeWarning $false | |
# sign in to Azure account | |
Connect-AzAccount | |
#Folder containing sql script and place to create Excel file |
This file contains hidden or 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-module az.sql | |
<# TODO | |
Based on: | |
https://learn.microsoft.com/en-us/azure/azure-sql/database/elastic-jobs-powershell-create?view=azuresql | |
* Add "Get" commants to top of script as appropriate | |
* Be able to loop through set of servers | |
* Document steps and/or separate files | |
* Parameterize passwords for master & job user accounts |
This file contains hidden or 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 master | |
go | |
-- Adds a first step to specified job, which checks whether running on Primary replica | |
create procedure dbo.AddAGPrimaryCheckStepToAgentJob | |
@jobname nvarchar(128) | |
as | |
set nocount on; |
This file contains hidden or 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 @CustomerID INT | |
SELECT @CustomerID = ? | |
IF NOT EXISTS (SELECT * | |
FROM WideWorldImportsDW.Dimension.Customer | |
WHERE [WWI Customer ID] = @CustomerID) | |
INSERT WideWorldImportersDW.Dimension.Customer | |
([WWI Customer ID], | |
Customer, | |
[Bill To Customer], |
NewerOlder