Posts

Installing Azure PowerShell Module in Your Local Windows PowerShell

Image
The Azure PowerShell Module can be used to automate the creation, management and deployment of resources in Microsoft Azure Portal, so it's very useful and we'd better have it installed in our local Windows PowerShell. We can simply follow the below steps to achieve this. I. Firstly launch Windows Powershell with an administrator’s credential and execute the $PSVersionTable.PSVersion command to check the current version of PowerShell that’s been installed. As per the below screenshot, the version installed in my machine is 5.1. This is the minimum version that’s required to install the Azure PowerShell module. II. Install .NET Framework 4.8 in your Windows system. In my case the install program indicates me that it’s already been installed.  III. In PowerShell run the Update-Module PowerShellGet -Force command to install the latest version of PowerShellGet. PowerShellGet is a module with commands for discovering,...

MERGE - A Neat Way to Do Type 2 Load

Image
In this post we'll introduce a way to load data into a Type 2 table in a neat and beautiful way. If you don't know what a Type 2 table (or Slow Changed Dimension Type 2) is, please read the book 'Data Warehouse Toolkit' by Ralph Kimball for details. Firstly, we use the below script to generate two temp tables and populate data into them. CREATE TABLE #Target        (               [ID] int               , [Name] varchar ( 16 )               , [IsEnabled] bit        ) INSERT INTO #Target VALUES ( 1 , 'Pepper' , 1 )        ,( 2 , 'Chilli' , 1 )        ,( 3 , 'Paprika' , 1 ) CREATE TABLE #Source        (  ...

sp_executesql – Let's learn How to Use It

Image
In the post SQL Server - Using SQL Agent JOBs to Scheduleand Execute Multiple Stored Procedures in Parallel , I’ve demonstrated the usage of sp_executesql and how powerful and helpful it is. This time I’ll put more explanations about it. Talk is cheap, and let’s see the code. DECLARE @ModDate datetime = '2017-12-04 00:00:00.000' SELECT        [AddressID]     , [AddressLine1]     , [AddressLine2]     , [City]     , [StateProvinceID]     , [PostalCode]     , [SpatialLocation]     , [rowguid]     , [ModifiedDate] FROM [AdventureWorks2017] . [Person] . [Address] WHERE [ModifiedDate] <= @ModDate The above code is straightforward enough. Now let’s consider the below scenarios – suppose our database name is composed by the keyword ‘AdventureWorks’ plus the year number suffix (in our example it’s 2017); ...