<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Databases Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/category/databases/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Tue, 30 Jan 2024 18:30:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Provision a database programmatically in Azure SQL database with a failover group</title>
		<link>https://blogit.create.pt/miguelisidoro/2024/01/24/provision-a-database-programmatically-in-azure-sql-database-with-a-failover-group/</link>
					<comments>https://blogit.create.pt/miguelisidoro/2024/01/24/provision-a-database-programmatically-in-azure-sql-database-with-a-failover-group/#respond</comments>
		
		<dc:creator><![CDATA[Miguel Isidoro]]></dc:creator>
		<pubDate>Wed, 24 Jan 2024 14:32:24 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft Azure]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12852</guid>

					<description><![CDATA[<p>This post will explain how to provision a database programmatically in a Azure SQL database and add it to an Azure SQL failover group. Introduction An Azure SQL Server failover group is a group of databases that can be automatically or manually failed over from a primary server to a secondary server in a different [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/miguelisidoro/2024/01/24/provision-a-database-programmatically-in-azure-sql-database-with-a-failover-group/">Provision a database programmatically in Azure SQL database with a failover group</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post will explain how to provision a database programmatically in a Azure SQL database and add it to an Azure SQL failover group.</p>



<h2 class="wp-block-heading">Introduction</h2>



<p>An Azure SQL Server failover group is a group of databases that can be automatically or manually failed over from a primary server to a secondary server in a different Azure region in case of a disaster in the primary server. Failover groups provide high availability and disaster recovery for Azure SQL Server databases.</p>



<p>The process described in this post is composed by two main steps:</p>



<ul class="wp-block-list">
<li>Provisioning the database</li>



<li>Adding the database to the failover group </li>
</ul>



<h2 class="wp-block-heading">Provisioning the database</h2>



<p>The first step is to create the database. This step is composed by the following actions:</p>



<ul class="wp-block-list">
<li>Get the tenant information</li>



<li>Create the database</li>
</ul>



<p>Tenant information class:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="791" height="381" src="https://blogit.create.pt/wp-content/uploads/2024/01/Regions.jpg" alt="" class="wp-image-12869" srcset="https://blogit.create.pt/wp-content/uploads/2024/01/Regions.jpg 791w, https://blogit.create.pt/wp-content/uploads/2024/01/Regions-300x145.jpg 300w, https://blogit.create.pt/wp-content/uploads/2024/01/Regions-768x370.jpg 768w, https://blogit.create.pt/wp-content/uploads/2024/01/Regions-696x335.jpg 696w" sizes="(max-width: 791px) 100vw, 791px" /></figure>



<p>Code to create database programatically:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="722" src="https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-1024x722.jpg" alt="" class="wp-image-12866" srcset="https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-1024x722.jpg 1024w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-300x212.jpg 300w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-768x542.jpg 768w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-696x491.jpg 696w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-596x420.jpg 596w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase-100x70.jpg 100w, https://blogit.create.pt/wp-content/uploads/2024/01/CreateDatabase.jpg 1065w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Adding the database to the failover group</h2>



<p>The second step adds the newly created database to the failover group. This step is composed by the following actions:</p>



<ul class="wp-block-list">
<li>Get the failover group where we want to add the database</li>



<li>Re-add the existing databases to the failover group &#8211; necessary since when we get the failover group the list of databases of the group is empty and, without this step, the failover group would only have the new database</li>



<li>Add the new database to the failover group</li>
</ul>



<figure class="wp-block-image size-full"><img decoding="async" width="790" height="344" src="https://blogit.create.pt/wp-content/uploads/2024/01/Failovergroup.jpg" alt="" class="wp-image-12876" srcset="https://blogit.create.pt/wp-content/uploads/2024/01/Failovergroup.jpg 790w, https://blogit.create.pt/wp-content/uploads/2024/01/Failovergroup-300x131.jpg 300w, https://blogit.create.pt/wp-content/uploads/2024/01/Failovergroup-768x334.jpg 768w, https://blogit.create.pt/wp-content/uploads/2024/01/Failovergroup-696x303.jpg 696w" sizes="(max-width: 790px) 100vw, 790px" /></figure>



<h2 class="wp-block-heading">Other Articles</h2>



<p>To learn why your business should migrate to SharePoint Online and Office 365, click <a href="https://blogit.create.pt////miguelisidoro/2019/07/29/why-your-business-should-migrate-to-sharepoint-online-and-office-365-the-value-offer-part-1/" target="_blank" rel="noreferrer noopener">here</a> and <a href="https://blogit.create.pt////miguelisidoro/2019/07/29/why-your-business-should-migrate-to-sharepoint-online-and-office-365-the-value-offer-part-2/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to learn how to develop SPFx solutions, click <a href="https://blogit.create.pt/miguelisidoro/2022/05/09/sharepoint-framework-spfx-learning-guide/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to learn how you can rename a modern SharePoint site, click <a href="https://blogit.create.pt////miguelisidoro/2019/09/23/how-to-rename-a-modern-sharepoint-site-url-in-office-365/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to learn how to save time time scheduling your meetings, click&nbsp;<a href="https://blogit.create.pt////miguelisidoro/2020/04/12/save-time-scheduling-microsoft-teams-meetings-using-findtime/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to learn how to enable Microsoft Teams Attendance List Download, click&nbsp;<a href="https://blogit.create.pt////miguelisidoro/2020/09/20/how-to-enable-teams-meeting-attendance-list-download-in-microsoft-365/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to learn how to create a dynamic org-wide team in Microsoft Teams with all active employees, click&nbsp;<a href="https://blogit.create.pt/miguelisidoro/2020/09/21/how-to-create-a-dynamic-team-in-microsoft-teams-with-all-active-employees-in-microsoft-365/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>If you want to modernize your SharePoint classic root site to a modern SharePoint site, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/08/27/how-to-modernize-your-tenant-root-site-collection-in-office-365-using-invoke-spositeswap/" target="_blank">here</a>.</p>



<p>If you are a SharePoint administrator or a SharePoint developer who wants to learn more about how to install a SharePoint 2019 farm in an automated way using PowerShell, I invite you to click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/12/09/how-to-install-a-sharepoint-2019-farm-using-powershell-and-autospinstaller-part-1/" target="_blank">here</a>&nbsp;and&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/12/09/how-to-install-a-sharepoint-2019-farm-using-powershell-and-autospinstaller-part-2/" target="_blank">here</a>.</p>



<p>If you learn how to greatly speed up your SharePoint farm update process to ensure your SharePoint farm keeps updated and you stay one step closer to start your move to the cloud, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/05/02/how-to-speed-up-the-installation-of-sharepoint-cumulative-updates-using-powershell-step-by-step/" target="_blank">here</a>.</p>



<p>If you prefer to use the traditional method to update your farm and want to learn all the steps and precautions necessary to successfully keep your SharePoint farm updated, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/04/08/how-to-install-sharepoint-cumulative-updates-in-a-sharepoint-farm-step-by-step/" target="_blank">here</a>.</p>



<p>If you want to learn how to upgrade a SharePoint 2013 farm to SharePoint 2019, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/03/06/how-to-upgrade-from-sharepoint-2013-to-sharepoint-2019-step-by-step-part-1/" target="_blank">here&nbsp;</a>and&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/03/06/how-to-upgrade-from-sharepoint-2013-to-sharepoint-2019-step-by-step-part-2/" target="_blank">here</a>.</p>



<p>If SharePoint 2019 is still not an option, you can learn more about how to install a SharePoint 2016 farm in an automated way using PowerShell, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/07/28/how-to-install-a-sharepoint-2016-farm-using-powershell-and-autospinstaller-part-1/" target="_blank">here</a>&nbsp;and&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/07/28/how-to-install-a-sharepoint-2016-farm-using-powershell-and-autospinstaller-part-2/" target="_blank">here</a>.</p>



<p>If you want to learn how to upgrade a SharePoint 2010 farm to SharePoint 2016, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/02/04/sharepoint-upgrade-upgrading-a-sharepoint-2010-farm-to-sharepoint-2016-step-by-step-part-1/" target="_blank">here&nbsp;</a>and&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/02/04/sharepoint-upgrade-upgrading-a-sharepoint-2010-farm-to-sharepoint-2016-step-by-step-part-2/" target="_blank">here</a>.</p>



<p>If you are new to SharePoint and Office 365 and want to learn all about it, take a look at these&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/10/17/sharepoint-and-office-365-learning-resources/" target="_blank">learning resources</a>.</p>



<p>If you are work in a large organization who is using Office 365 or thinking to move to Office 365 and is considering between a single or multiple Office 365 tenants, I invite you to read&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2019/01/07/pros-and-cons-of-single-tenant-vs-multiple-tenants-in-office-365/" target="_blank">this article</a>.</p>



<p>If you want to know all about the latest SharePoint and Office 365 announcements from Ignite and some more recent announcements, including Microsoft Search, What’s New to Build a Modern Intranet with SharePoint in Office 365, Deeper Integration between Microsoft Teams and SharePoint and the latest news on SharePoint development, click&nbsp;<a rel="noreferrer noopener" href="https://blogit.create.pt////miguelisidoro/2018/11/21/whats-new-for-sharepoint-and-office-365-after-microsoft-ignite-2018/" target="_blank">here</a>.</p>



<p>If your organization is still not ready to go all in to SharePoint Online and Office 365, a hybrid scenario may be the best choice. SharePoint 2019 RTM was recently announced and if you to learn all about SharePoint 2019 and all its features, click <a href="https://blogit.create.pt////miguelisidoro/2018/11/01/meet-the-new-modern-sharepoint-server-sharepoint-2019-rtm-is-here/" target="_blank" rel="noreferrer noopener">here</a>.</p>



<p>Happy Coding!</p>
<p>The post <a href="https://blogit.create.pt/miguelisidoro/2024/01/24/provision-a-database-programmatically-in-azure-sql-database-with-a-failover-group/">Provision a database programmatically in Azure SQL database with a failover group</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/miguelisidoro/2024/01/24/provision-a-database-programmatically-in-azure-sql-database-with-a-failover-group/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Entity Framework &#8211; Update Database using Azure Pipelines</title>
		<link>https://blogit.create.pt/vini/2022/11/07/entity-framework-update-database-using-azure-pipelines/</link>
					<comments>https://blogit.create.pt/vini/2022/11/07/entity-framework-update-database-using-azure-pipelines/#respond</comments>
		
		<dc:creator><![CDATA[Vinícius Biavatti]]></dc:creator>
		<pubDate>Mon, 07 Nov 2022 11:18:06 +0000</pubDate>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Microsoft Azure]]></category>
		<category><![CDATA[azure]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[entity framework]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[pipelines]]></category>
		<category><![CDATA[sql database]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12770</guid>

					<description><![CDATA[<p>Introduction The pipelines bring to us the opportunity to create automatic tasks to execute development operations, like deploys, migrations, tests, etc. Focused in the deploy routine, some applications need other operations to ensure the stability between the application and other resources, like the database. During the development process, the developers usually customize and improve the [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/vini/2022/11/07/entity-framework-update-database-using-azure-pipelines/">Entity Framework &#8211; Update Database using Azure Pipelines</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Introduction</h2>



<p>The pipelines bring to us the opportunity to create automatic tasks to execute development operations, like deploys, migrations, tests, etc. Focused in the deploy routine, some applications need other operations to ensure the stability between the application and other resources, like the database.</p>



<p>During the development process, the developers usually customize and improve the application database in the development environment scope, and it can be made easily by using frameworks that contains routines to create source files that have the responsability to keep the history of changes and are used to update the database for determinated version. These files are known as migrations.&nbsp;</p>



<p>In this post, we will see how to apply migrations for the databases that are located in different environments (staging, production, etc.), using the Code-First entity concept, and the Entity Framework Core.</p>



<h2 class="wp-block-heading">Migrations</h2>



<p>To generate database migrations, we can execute the &#8220;Add-Migraton &lt;name&gt;&#8221; command from the Entity Framework. This command will generate some source files that will contain the code to apply the migration to the database. To execute these migration files, you just need to execute the &#8220;Update-Database&#8221; command. But,&nbsp;<a href="https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#sql-scripts" target="_blank" rel="noreferrer noopener">Microsoft recommends</a>&nbsp;to create a SQL file individually, and suggest to execute this file direct to the database, without need to execute an intermediary software (C# + EF) to access the database. To do this, we will have to follow the steps below:</p>



<ul class="wp-block-list">
<li>1. Create a Pipeline in Azure Devops;</li>



<li>2. Install dotnet-ef-tool;</li>



<li>3. Generate SQL script;</li>



<li>4. Execute SQL script to the database;</li>



<li>5. Script File as a Pipeline Artifact.</li>
</ul>



<p><em><strong>NOTE</strong>: We don&#8217;t need to worry about which migration need to be applyed to the database. The dotnet-ef-tool command will generate a script cantaining the needed logic. Check the third step for more details.</em></p>



<h2 class="wp-block-heading">1. Create a Pipeline in Azure Devops</h2>



<p>We will create a common deployment pipeline in Azure Devops for ASP.NET Core backend applications. Check the end of the post to see the full result of the pipeline.</p>



<h2 class="wp-block-heading">2. Install dotnet-ef-tool</h2>



<p>To execute tool commands of Entity Framework, we have to install a package named dotnet-ef-tool. This needs to be available into the pipeline&#8217;s context to be used for the SQL script generation. To install this tool by a pipeline task, we can use the task below:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
- task: DotNetCoreCLI@2
  displayName: &#039;Install EF tool&#039;
  inputs:
    command: &#039;custom&#039;
    custom: &#039;tool&#039;
    arguments: &#039;install --global dotnet-ef&#039;
</pre></div>


<h2 class="wp-block-heading">3. Generate SQL script</h2>



<p>To generate the SQL script containing the logic to apply migrations, we will use the dotnet-ef-tool. By default, the command does not generate the logic to check which migration should be applied, so we have to enable this behavior using the parameter: &#8211;idempotent. By using this behavior, we don&#8217;t need to worry about the migrations that will be applyed to the database since the generated script already has it. Below, you can see the task that could be used to generate the script file:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
- task: DotNetCoreCLI@2
  displayName: &#039;Generate SQL Script&#039;
  inputs:
    command: &#039;custom&#039;
    custom: &#039;ef&#039;
    arguments: &#039;migrations script --idempotent --project $(Build.SourcesDirectory)\Data.csproj --output $(System.ArtifactsDirectory)/script.sql&#039;
</pre></div>


<p><em><strong>NOTE</strong>: We don&#8217;t need to stablish any database connection for the script generation, since we are following the Code First concept for entity creation, so, the command will just look at the entities source code of the project to generate the SQL file. If we don&#8217;t use the &#8211;idempotent argument, the script will generate the SQL without the conditional logic to determinate which migration should be applied, causing an error if the database already exists.</em></p>



<h2 class="wp-block-heading">4. Execute SQL script to the database</h2>



<p>Now, with the SQL script available, we just need to execute this file to the database. In this post, we will use a common Azure Database as an example, so for this case, we can use the following task to accomplish this requirement:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
- task: SqlAzureDacpacDeployment@1
  displayName: &#039;Update Database&#039;
  inputs:
    azureSubscription: &#039;&lt;Service Connection Identifier&gt;&#039;
    AuthenticationType: &#039;connectionString&#039; # You can use other method to authenticate to the database if you want
    ConnectionString: &#039;&lt;Database Connection String&gt;&#039;
    deployType: &#039;SqlTask&#039;
    SqlFile: &#039;$(System.ArtifactsDirectory)/script.sql&#039;
</pre></div>


<h2 class="wp-block-heading">5. Script File as a Pipeline Artifact</h2>



<p>Well done. The last task will only be used to make the file available to be accessed by the pipeline runner user. To do this, you can use the task below to add the generated script.sql file to the file bundle (artifacts). To check the artifacts, just access the artifacts option from the pipeline details after the job&#8217;s execution.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
- task: PublishBuildArtifacts@1
  displayName: &#039;Publish Artifacts&#039;
  inputs:
    PathtoPublish: &#039;$(System.ArtifactsDirectory)/script.sql&#039;
    ArtifactName: &#039;$(artifactName)&#039;
    publishLocation: &#039;Container&#039;
</pre></div>


<h2 class="wp-block-heading">Conclusion</h2>



<p>In this post, we could learn an easy way to apply the database migrations to the remote environment by using automation (pipelines) to accomplish it. This method is simple, and does not have any database validation before script execution. So, if you have an active and sensitive environment, be sure that the needed validations are considered before the database update, to ensure that the database will not be update wrongly.</p>



<h2 class="wp-block-heading">Pipeline Result</h2>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
trigger:
- none

pool:
  vmImage: windows-latest

variables:
  solution: &#039;**/*.sln&#039;
  buildPlatform: &#039;AnyCPU&#039;
  buildConfiguration: &#039;Release&#039;
  artifactName: &#039;artifacts&#039;
  environment: &#039;Development&#039;

- task: NuGetToolInstaller@1
  displayName: &#039;NuGet Installation&#039;

- task: NuGetCommand@2
  displayName: &#039;NuGet Restore&#039;
  inputs:
    restoreSolution: &#039;$(solution)&#039;

- task: VSBuild@1
  displayName: &#039;Build Project&#039;
  inputs:
    solution: &#039;backend/WebAPI&#039;
    msbuildArgs: &#039;/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=&quot;$(build.artifactStagingDirectory)&quot;&#039;
    platform: &#039;$(buildPlatform)&#039;
    configuration: &#039;$(buildConfiguration)&#039;

- task: PublishSymbols@2
  displayName: &#039;Publish Symbols&#039;
  inputs:
    SearchPattern: &#039;**/bin/**/*.pdb&#039;
    SymbolServerType: &#039;FileShare&#039;
    CompressSymbols: false

- task: PublishBuildArtifacts@1
  displayName: &#039;Publish Artifacts&#039;
  inputs:
    PathtoPublish: &#039;$(Build.ArtifactStagingDirectory)&#039;
    ArtifactName: &#039;artifacts&#039;
    publishLocation: &#039;Container&#039;

- task: DownloadBuildArtifacts@0
  displayName: &#039;Build Artifacts&#039;
  inputs:
    buildType: &#039;current&#039;
    downloadType: &#039;single&#039;
    artifactName: &#039;$(artifactName)&#039;
    downloadPath: &#039;$(System.ArtifactsDirectory)&#039;

- task: DotNetCoreCLI@2
  displayName: &#039;Install EF tool&#039;
  inputs:
    command: &#039;custom&#039;
    custom: &#039;tool&#039;
    arguments: &#039;install --global dotnet-ef&#039;

- task: DotNetCoreCLI@2
  displayName: &#039;Generate SQL Script&#039;
  inputs:
    command: &#039;custom&#039;
    custom: &#039;ef&#039;
    arguments: &#039;migrations script --idempotent --project $(Build.SourcesDirectory)\Data.csproj --output $(System.ArtifactsDirectory)/script.sql&#039;

- task: SqlAzureDacpacDeployment@1
  displayName: &#039;Update Database&#039;
  inputs:
    azureSubscription: &#039;&lt;Service Connection Identifier&gt;&#039;
    AuthenticationType: &#039;connectionString&#039;
    ConnectionString: &#039;&lt;Connection String&gt;&#039;
    deployType: &#039;SqlTask&#039;
    SqlFile: &#039;$(System.ArtifactsDirectory)/script.sql&#039;

- task: AzureRmWebAppDeployment@4
  displayName: &#039;Deploy Application&#039;
  inputs:
    ConnectionType: &#039;AzureRM&#039;
    azureSubscription: &#039;&lt;Service Connection Identifier&gt;&#039;
    appType: &#039;webApp&#039;
    WebAppName: &#039;armazemlegalapi&#039;
    deployToSlotOrASE: true
    ResourceGroupName: &#039;&lt;Resource Group Identifier&gt;&#039;
    SlotName: &#039;production&#039;
    packageForLinux: &#039;$(System.ArtifactsDirectory)/Project.zip&#039;

- task: PublishBuildArtifacts@1
  displayName: &#039;Publish Artifacts&#039;
  inputs:
    PathtoPublish: &#039;$(System.ArtifactsDirectory)/script.sql&#039;
    ArtifactName: &#039;$(artifactName)&#039;
    publishLocation: &#039;Container&#039;
</pre></div>


<h2 class="wp-block-heading">References</h2>



<ul class="wp-block-list">
<li><a href="https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#sql-scripts">Microsoft Managing Schemas Article</a></li>
</ul>
<p>The post <a href="https://blogit.create.pt/vini/2022/11/07/entity-framework-update-database-using-azure-pipelines/">Entity Framework &#8211; Update Database using Azure Pipelines</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/vini/2022/11/07/entity-framework-update-database-using-azure-pipelines/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>.NET EF Core 6 support for groupby top(n) queries</title>
		<link>https://blogit.create.pt/telmorodrigues/2022/02/04/net-ef-core-6-support-for-groupby-topn-queries/</link>
					<comments>https://blogit.create.pt/telmorodrigues/2022/02/04/net-ef-core-6-support-for-groupby-topn-queries/#respond</comments>
		
		<dc:creator><![CDATA[Telmo Rodrigues]]></dc:creator>
		<pubDate>Fri, 04 Feb 2022 16:14:46 +0000</pubDate>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Sql]]></category>
		<category><![CDATA[entity framework]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12605</guid>

					<description><![CDATA[<p>EF Core 6 comes with some GroupBy queries improvements. In this post I wanna talk about the improvements related to &#8220;group by top(n)&#8221; queries. Let&#8217;s say we have the following table Documents: and that we want to get the two most recent documents for each user. For instance, if we have the following records: the [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/telmorodrigues/2022/02/04/net-ef-core-6-support-for-groupby-topn-queries/">.NET EF Core 6 support for groupby top(n) queries</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>EF Core 6 comes with some GroupBy queries improvements. In this post I wanna talk about the improvements related to &#8220;group by top(n)&#8221; queries.</p>



<p></p>



<p></p>



<p>Let&#8217;s say we have the following table Documents:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
CREATE TABLE &#x5B;dbo].&#x5B;Documents](
    &#x5B;Id] &#x5B;integer] PRIMARY KEY,
    &#x5B;UserId] &#x5B;integer] NOT NULL,
    &#x5B;Title] &#x5B;nvarchar](50) NOT NULL,
    &#x5B;Body] &#x5B;nvarchar](250) NOT NULL,
    &#x5B;CreatedOn] &#x5B;datetime] NOT NULL
)
</pre></div>


<p>and that we want to get the two most recent documents for each user. For instance, if we have the following records:</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://blogit.create.pt/wp-content/uploads/2022/02/image-6.png" alt="" class="wp-image-12606" width="523" height="183" srcset="https://blogit.create.pt/wp-content/uploads/2022/02/image-6.png 523w, https://blogit.create.pt/wp-content/uploads/2022/02/image-6-300x105.png 300w" sizes="(max-width: 523px) 100vw, 523px" /></figure>



<p>the query should return</p>



<figure class="wp-block-image size-full"><img decoding="async" width="520" height="146" src="https://blogit.create.pt/wp-content/uploads/2022/02/image-7.png" alt="" class="wp-image-12607" srcset="https://blogit.create.pt/wp-content/uploads/2022/02/image-7.png 520w, https://blogit.create.pt/wp-content/uploads/2022/02/image-7-300x84.png 300w" sizes="(max-width: 520px) 100vw, 520px" /></figure>



<p>To do this query using EF Core and LINQ we can try to group the Documents by UserId and then sort each group by the CreatedOn column to pick the first two documents for each user.</p>



<p>We can start by trying to group all documents for each user</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
 var usersDocs = await ctx
        .Documents
        .GroupBy(doc =&gt; doc.UserId)
</pre></div>


<p>and then for each group we try to sort its elements by the CreatedOn column</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
    var usersDocs = await ctx
        .Documents
        .GroupBy(doc =&gt; doc.UserId)
        .SelectMany(userDocs =&gt; userDocs.OrderByDescending(doc =&gt; doc.CreatedOn).Take(2))
        .ToArrayAsync();
</pre></div>


<p>If we try to execute this query using a previous version of EF Core 6 we get the following error:</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
    .OrderByDescending(doc =&amp;gt; doc.CreatedOn)&#039; could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to &#039;AsEnumerable&#039;, &#039;AsAsyncEnumerable&#039;, &#039;ToList&#039;, or &#039;ToListAsync&#039;. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.&#039;
</pre></div>


<p></p>



<p>This is because the previous versions of EF don&#8217;t know how to translate the GroupBy inner expressions to sql. After following their suggestion I ended up with this query</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
    var usersDocs = await ctx
        .Documents
        .Select(doc =&gt; doc.UserId)
        .Distinct()
        .SelectMany(userId =&gt; 
            ctx
            .Documents
            .Where(doc =&gt; doc.UserId == userId)
            .OrderByDescending(doc =&gt; doc.CreatedOn)
            .Take(2)
        )
        .ToArrayAsync();
</pre></div>


<p>However this query has two main issues. It does a distinct over the UserId column, loads all the user ids to application memory and then it does a query for each user resulting in a n+1 query problem.</p>



<p>One way to solve these issues is to forget LINQ and rewrite the query using raw sql with a partition by UserId and the ROW_NUMBER() window funtion, doing a CTE .</p>



<p>Now, with the EF Core 6 we can use the first version of the query, since the EF Core team has added the support for translating some GroupBy inner expressions and it can translate this LINQ query to a single sql query.</p>



<p></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; title: ; notranslate">
    var usersDocs = await ctx
        .Documents
        .GroupBy(doc =&gt; doc.UserId)
        .SelectMany(userDocs =&gt; userDocs.OrderByDescending(doc =&gt; doc.CreatedOn).Take(2))
        .ToArrayAsync();
</pre></div>


<p>You can read more about these features and other improvements added to GroupBy queries&nbsp;<a href="https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/whatsnew#improved-groupby-support">here</a>&nbsp;and check the related github issues&nbsp;<a href="https://github.com/dotnet/efcore/issues/12088">12088</a>&nbsp;<a href="https://github.com/dotnet/efcore/issues/13805">13805</a>&nbsp;</p>



<p>Happy coding!</p>
<p>The post <a href="https://blogit.create.pt/telmorodrigues/2022/02/04/net-ef-core-6-support-for-groupby-topn-queries/">.NET EF Core 6 support for groupby top(n) queries</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/telmorodrigues/2022/02/04/net-ef-core-6-support-for-groupby-topn-queries/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>NoSQL First Act &#8211; a historical introduction</title>
		<link>https://blogit.create.pt/goncalomelo/2019/08/13/nosql-first-act-a-historical-introduction/</link>
					<comments>https://blogit.create.pt/goncalomelo/2019/08/13/nosql-first-act-a-historical-introduction/#respond</comments>
		
		<dc:creator><![CDATA[Gonçalo Melo]]></dc:creator>
		<pubDate>Tue, 13 Aug 2019 17:57:42 +0000</pubDate>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Sql]]></category>
		<category><![CDATA[Cluster]]></category>
		<category><![CDATA[Database history]]></category>
		<category><![CDATA[Database model]]></category>
		<category><![CDATA[Horizontal scale]]></category>
		<category><![CDATA[impedance mismatch]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Relational database]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Vertical scale]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=9739</guid>

					<description><![CDATA[<p>NoSQL databases introduction and dominant features. A historical perspective to their appearance in a world dominated by relational model databases.</p>
<p>The post <a href="https://blogit.create.pt/goncalomelo/2019/08/13/nosql-first-act-a-historical-introduction/">NoSQL First Act &#8211; a historical introduction</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>NoSQL gets a lot of &#8220;heat&#8221; about not having a good direct definition. And the term NoSQL only gives somes clues of what this is not. </p>



<p>NoSQL is like a new definition of something that is a database but is different than the usual relational model. Likewise, making a parallel by going back 30 years ago. Back then probably no one knew what a relational database was also. Let&#8217;s use this and start with a small historical and motivational point of view for NoSQL. PS: I was not a developer back then.</p>



<p>This article will be a first part of a series of articles. The goal will be to unite some knowledge about this topic. </p>



<h2 class="wp-block-heading">Starting in the 1980&#8217;s</h2>



<p>Relational databases emerged bringing ACID properties &#8211; Atomicity, Consistency, Isolation and Persistency. Properties taken for granted nowadays. Also, they also brought the SQL language. SQL is common enough across different systems for one to use. Although there are different flavors, can almost be considered a standard.</p>



<p>Relation databases also allowed for a simple and very common integration mechanism between 2 or more systems. Data can be easily shared by reading or writing data in a table on a shared relational database. This is today still a very common integration pattern.</p>



<h2 class="wp-block-heading">In the 1990&#8217;s</h2>



<p>Object database&#8217;s started to appear with more strength. They had been around for some time. Most important, they implement a different database paradigm model. This new paradigm tried to solve the impedance mismatch problem. The impedance mismatch was caused by relational databases. It emerges from the need to map objects used in memory in our application model to tables in a relational database. This page <a href="https://en.wikipedia.org/wiki/Object-relational_impedance_mismatch">https://en.wikipedia.org/wiki/Object-relational_impedance_mismatch</a> is a good reference for this issue.</p>



<p>Saving an application object into these database model should be a direct operation. Conceptually no mapping would be necessary when an object database type was used. Albeit, these gains, object databases were not able to substitute relational databases. </p>



<h2 class="wp-block-heading">In the 2000&#8217;s</h2>



<p>As internet availability grows 2 things started to have a big impact:</p>



<ul class="wp-block-list"><li>Generation of enormous amount of data that had to be stored and processed;</li><li>Accesses from anywhere in the globe became more and more frequent. Therefore latency was an issue to consider. And even speed of light limitation can contribute significantly to this. Data can now be stored far from where we are. For example, a distance of 10.000 km will add about 100 ms on each round trip. Therefore, data needs to spread around the globe to provide a quick access.</li></ul>



<p>In this environment,
relational databases do not always solve customer needs, either because of
flexibility, price or performance issues:</p>



<ul class="wp-block-list"><li>Relational databases enforces a ridged set of rules in the relational model. These will impact the flexibility of the application development;</li><li>Price because of the need for more powerful machines and also the software licenses that go with this;</li><li>Performance, because relational databases do not naturally meet the increasing workload. Huge CPU, memory, storage and throughput is needed to be perform in this environment. And for relational model, vertical scaling can only get you so far.</li></ul>



<h2 class="wp-block-heading">Scaling Vertically versus Horizontally</h2>



<p>Relational databases usual scaling method is a vertical one. As a result whenever the workload incresses we will use a bigger machine with more hardware resources. </p>



<p>On the other hand, the big internet companies adopted an horizontal scaling paradigm. This is a cluster type environment with lots and lots of machines. In other words, this means that more machines will be used to handle bigger workloads.</p>



<p>Relational databases do not thrive very well in this paradigm. They hardly take any benefit of using more machines. Hence, NoSQL like databases arises to take advantage of the horizontal scale paradigm. Also companies like Google and Amazon started researching in this area. As a result, Google created BigTable and Amazon DynamoDB.</p>



<h2 class="wp-block-heading">Relational databases dominated the market, why are NoSQL databases being used now?</h2>



<p>I think this is important. Dominance and usage factors are usually a combination of several aspects. What has been changing:</p>



<ul class="wp-block-list"><li>Developers hide databases behind integration layers. This makes it simpler to use. And in addition, easier to replace one database or persistence method per other; </li><li>Cloud growth in some cases means we can try different approaches with less effort regarding infrastructure;</li><li>Handling big quantities of data introduced new needs. NoSQL provides a good development flexibility. And in addition can also take advantage of cluster solutions.</li></ul>



<p>Finally, what is NoSQL?</p>



<h2 class="wp-block-heading">Common NoSQL databases characteristics</h2>



<p>NoSQL doesn’t have a clear direct meaning. The term alludes to something like &#8220;Not Only SQL&#8221;. A more exact explanation should be &#8220;Non Relational database&#8221;. This would reinforce the new model paradigm and not the SQL language itself. The fact that some NoSQL databases actually supports some form of SQL language adds even more to the confusion.</p>



<p>But, the name is catchy and so common that will probably stay. The point is: defining NoSQL is hard. Therefore, we will do the next best thing. Introduce the dominant traits of these database systems:</p>



<ul class="wp-block-list"><li>Non relational;</li><li>Usually (not all) cluster-friendly;</li><li>Most of them are open source;</li><li>No-schema / schema-less;</li><li>Have a big internet drive (cluster and bigdata friendly).</li></ul>



<p>By these common traits, almost any non relational database can be a NoSQL database! Also, there are probably published studies in all these areas dating back 30 or 40 year ago. Out of curiosity, the name NoSQL itself is referred to being born by the end of 2009. The term emerged as a twitter hashtag for a meetup were people talked about these subjects. Even though some of these traits were not new at the time.</p>



<h2 class="wp-block-heading">Next steps</h2>



<p>NoSQL has a lot to explore. It will provide a more direct paradigm that will make simpler specific needs like this ones to <a href="https://blogit.create.pt////diogoguiomar/2018/02/26/query-a-json-array-column-in-sql/">query Json objects inside Sql Server</a> and <a href="https://blogit.create.pt////goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/">performance considerations</a>.</p>



<p>My plan for the next article(s) will be to:</p>



<ul class="wp-block-list"><li>Present some of the NoSQL data models; </li><li>Talk about the no schema or the schema less feature;</li><li>Discuss the aggregate concept. And how this relates to the CAP theorem.</li></ul>



<h2 class="wp-block-heading">Further reads</h2>



<p>There is a lot of information online. For me, I like Martin Fowler approach. Some of these information&#8217;s are from his content. You can check his website here: <a href="https://martinfowler.com/nosql.html">https://martinfowler.com/nosql.html</a>. He also has a book: <a href="https://martinfowler.com/books/nosql.html">https://martinfowler.com/books/nosql.html</a>.</p>



<p></p>
<p>The post <a href="https://blogit.create.pt/goncalomelo/2019/08/13/nosql-first-act-a-historical-introduction/">NoSQL First Act &#8211; a historical introduction</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/goncalomelo/2019/08/13/nosql-first-act-a-historical-introduction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Query performance for JSON objects inside SQL Server using JSON_VALUE function</title>
		<link>https://blogit.create.pt/goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/</link>
					<comments>https://blogit.create.pt/goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/#comments</comments>
		
		<dc:creator><![CDATA[Gonçalo Melo]]></dc:creator>
		<pubDate>Thu, 20 Dec 2018 09:39:12 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=8077</guid>

					<description><![CDATA[<p>Following up on this article about querying JSON Data I would like to talk about how to improve searches on JSON data inside SQL Server. Starting SQL Server 2016 Microsoft deployed a set of functions that allow us to work with JSON data in a structured way inside SQL Server. I will introduce a small [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/">Query performance for JSON objects inside SQL Server using JSON_VALUE function</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Following up on <a href="https://blogit.create.pt////diogoguiomar/2018/02/26/query-a-json-array-column-in-sql/">this article about querying JSON Data</a> I would like to talk about how to improve searches on JSON data inside SQL Server. Starting SQL Server 2016 Microsoft deployed a set of functions that allow us to work with JSON data in a structured way inside SQL Server.</p>



<p>I will introduce a small usage sample for the <strong>JSON_VALUE </strong>function in combination with indexes to improve information retrieval from a table containing one JSON object. For our testes, we have a <strong>UserDetailTest </strong>table that has more than 500k rows with 2 columns: an UserId and a nvarchar(max) to hold a small JSON details string like the following:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SELECT *, LEN(DetailsJSON) AS &#x5B;Len(DetailsJSON)] FROM UserDetailTest
</pre></div>


<figure class="wp-block-image"><img decoding="async" width="937" height="188" src="https://blogit.create.pt////wp-content/uploads/2018/12/sampleTable.png" alt="" class="wp-image-8153" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/sampleTable.png 937w, https://blogit.create.pt/wp-content/uploads/2018/12/sampleTable-300x60.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/sampleTable-768x154.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/sampleTable-696x140.png 696w" sizes="(max-width: 937px) 100vw, 937px" /></figure>



<p>I will activate time statistics and clean SQL Server cache between each query to have some consistency across the execution times using the following SQL statements:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
CHECKPOINT
DBCC DROPCLEANBUFFERS
SET STATISTICS TIME ON
</pre></div>


<h2 class="wp-block-heading">JSON_VALUE Function intro</h2>



<p>The JSON_VALUE function extracts a value from a JSON string. This functions receives 2 arguments, the first being an expression for the JSON value and the second a path for the value we want to obtain. A simple sample with an inline JSON object would be the following:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
SELECT JSON_VALUE('{"PostalCode":"376-3765","PhoneNumber":"351003765718"}', '$.PhoneNumber')
</pre></div>


<figure class="wp-block-image"><img decoding="async" width="1245" height="123" src="https://i1.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult0.png?fit=696%2C69&amp;ssl=1" alt="" class="wp-image-8182" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0.png 1245w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0-300x30.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0-768x76.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0-1024x101.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0-696x69.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult0-1068x106.png 1068w" sizes="(max-width: 1245px) 100vw, 1245px" /></figure>



<p>The return is a scalar value (nvarchar(4000)) for the PhoneNumber element.</p>



<h2 class="wp-block-heading">Query scenarios</h2>



<p>Starting with one of the <strong>really&nbsp;worst </strong>case scenario (yes, this can happen&#8230;):</p>



<figure class="wp-block-image"><img decoding="async" width="1024" height="240" src="https://blogit.create.pt////wp-content/uploads/2018/12/selectResult20-1024x240.png" alt="" class="wp-image-8197" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20-1024x240.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20-300x70.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20-768x180.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20-696x163.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20-1068x250.png 1068w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult20.png 1275w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>More than 17 seconds really seems like a worst scenario! Next, we will use the JSON_VALUE function to get the PhoneNumber from the JSON string and use it in our where clause:</p>



<figure class="wp-block-image"><img decoding="async" width="1266" height="301" src="https://i1.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult22.png?fit=696%2C165&amp;ssl=1" alt="" class="wp-image-8198" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22.png 1266w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22-300x71.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22-768x183.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22-1024x243.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22-696x165.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult22-1068x254.png 1068w" sizes="(max-width: 1266px) 100vw, 1266px" /></figure>



<p>This still takes more than 3 seconds. A good improvement, but yet a high cost if we need to search information in this way.</p>



<h2 class="wp-block-heading" id="mce_9">Index creation</h2>



<p>Let&#8217;s add a new virtual column to table that displays the result from the JSON_VALUE function &#8211; this will allow us to create an index and simplify the SELECT queries.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
ALTER TABLE UserDetailTest 
	ADD vPhoneNumber AS 
	CAST(JSON_VALUE(DetailsJSON, '$.PhoneNumber') AS NVARCHAR(255));
</pre></div>


<p>The cast truncates the output from the JSON_VALUE&nbsp;to ensure that it does not exceed the maximum lenght for the index key. Now, if we search using the column, the result is still more or less the same 3 seconds has before:</p>



<ul class="wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><li class="blocks-gallery-item"><figure><img decoding="async" width="1274" height="311" src="https://i1.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult23.png?fit=696%2C170&amp;ssl=1" alt="" data-id="8199" data-link="https://blogit.create.pt////?attachment_id=8199" class="wp-image-8199" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23.png 1274w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23-300x73.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23-768x187.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23-1024x250.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23-696x170.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult23-1068x261.png 1068w" sizes="(max-width: 1274px) 100vw, 1274px" /></figure></li></ul>



<p>Let&#8217;s create an index and perform the search again:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
CREATE INDEX idx_vPhoneNumber ON &#x5B;UserDetailTest] (vPhoneNumber);

</pre></div>


<ul class="wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex"><li class="blocks-gallery-item"><figure><img decoding="async" width="1270" height="316" src="https://i1.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult24.png?fit=696%2C173&amp;ssl=1" alt="" data-id="8201" data-link="https://blogit.create.pt////?attachment_id=8201" class="wp-image-8201" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24.png 1270w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24-300x75.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24-768x191.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24-1024x255.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24-696x173.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult24-1068x266.png 1068w" sizes="(max-width: 1270px) 100vw, 1270px" /></figure></li></ul>



<p>Consequently the improvement is huge, 13 miliseconds is more interesting! But what&#8217;s the cost?</p>



<h2 class="wp-block-heading">The cost</h2>



<p>When we create an index, we&#8217;re basically trading space for time &#8211; more occupied space versus faster operations. Therefore let&#8217;s see what the increase is using&nbsp;<strong>sp_spaceused</strong> function before and after index creation:</p>



<table class="wp-block-table is-style-regular"><tbody><tr><td></td><td><strong>rows</strong></td><td><strong>reserved</strong></td><td><strong>data</strong></td><td><strong>index_size</strong></td><td><strong>unused</strong></td></tr><tr><td><strong>Initial</strong></td><td>557801              </td><td>1120904 KB</td><td>1115584 KB</td><td>5224 KB</td><td>96 KB</td></tr><tr><td><strong>After Index</strong></td><td>557801</td><td>1148752 KB</td><td>1115584 KB</td><td>32992 KB</td><td>176 KB</td></tr></tbody></table>



<p>Probably, an interesting comparison would be if the PhoneNumber column was an explicit column in that table containing the value. Let&#8217;s do that!</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: sql; title: ; notranslate">
ALTER TABLE UserDetailTest  
	ADD PhoneNumberCopy NVARCHAR(255)

UPDATE UserDetailTest
	SET PhoneNumberCopy = vPhoneNumber
</pre></div>


<p>The sp_spaceused remained the same &#8211; SQL Server internal black magic regarding space allocation (for another time!). But performance wise, for this approach in my machine this query still took more than 2 seconds to complete:</p>



<figure class="wp-block-image"><img decoding="async" width="1269" height="362" src="https://i2.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult26.png?fit=696%2C198&amp;ssl=1" alt="" class="wp-image-8203" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26.png 1269w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26-300x86.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26-768x219.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26-1024x292.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26-696x199.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult26-1068x305.png 1068w" sizes="(max-width: 1269px) 100vw, 1269px" /></figure>



<p>Slightly better than the query with the JSON function but the advantage is that in this scenario SQL can better optimize the searches. The following runs of the same query without clearing the cache returns results much faster &#8211; each took around 220 miliseconds to complete:</p>



<figure class="wp-block-image"><img decoding="async" width="1263" height="343" src="https://i2.wp.com/blogit.create.pt/wp-content/uploads/2018/12/selectResult27.png?fit=696%2C189&amp;ssl=1" alt="" class="wp-image-8204" srcset="https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27.png 1263w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27-300x81.png 300w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27-768x209.png 768w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27-1024x278.png 1024w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27-696x189.png 696w, https://blogit.create.pt/wp-content/uploads/2018/12/selectResult27-1068x290.png 1068w" sizes="(max-width: 1263px) 100vw, 1263px" /></figure>



<h2 class="wp-block-heading">Summary Results</h2>



<p>Just to sum up all the results for the different types of searches comparing the first execution after cache clean up and the following runs.&nbsp;I did several iterations for each step just to make sure the results were consistent&nbsp;although the goal was just to have a baseline. Certanly, the use of this will depend on each case.</p>



<table class="wp-block-table"><tbody><tr><td><strong>WHERE clausule type</strong></td><td><strong>First run</strong></td><td><strong>Following runs</strong></td></tr><tr><td><pre class="brush: sql; gutter: false; title: ; notranslate">WHERE DetailsJson LIKE '%PhoneNumber&quot;:&quot;351003765718&quot;%'</pre></td><td>17754 ms</td><td>around the same</td></tr><tr><td><pre class="brush: sql; gutter: false; title: ; notranslate">WHERE JSON_VALUE(DetailsJson, '$.PhoneNumber') = '351003765718'</pre></td><td>3375 ms</td><td>1958 ms</td></tr><tr><td><pre class="brush: sql; gutter: false; title: ; notranslate">WHERE vPhoneNumber = '351003765718'</pre>vPhoneNumber is not indexed&nbsp;</td><td>3339 ms</td><td>1332 ms</td></tr><tr><td><pre class="brush: sql; gutter: false; title: ; notranslate">WHERE vPhoneNumber = '351003765718'</pre> vPhoneNumber is indexed</td><td>13 ms</td><td>0 ms</td></tr><tr><td><pre class="brush: sql; gutter: false; title: ; notranslate">WHERE PhoneNumberCopy  = '351003765718'</pre>PhoneNumberCopy&nbsp; is of type nvarchar(255) and explicitly contains all values</td><td>2309 ms</td><td>222 ms</td></tr></tbody></table>



<p></p>
<p>The post <a href="https://blogit.create.pt/goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/">Query performance for JSON objects inside SQL Server using JSON_VALUE function</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/goncalomelo/2018/12/20/query-performance-for-json-objects-inside-sql-server/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
		<item>
		<title>Converting a Vertical Table to an Horizontal Table in SQL Server</title>
		<link>https://blogit.create.pt/ricardocosta/2016/10/27/converting-a-vertical-table-to-an-horizontal-table-in-sql-server/</link>
					<comments>https://blogit.create.pt/ricardocosta/2016/10/27/converting-a-vertical-table-to-an-horizontal-table-in-sql-server/#comments</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Thu, 27 Oct 2016 21:24:13 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sql]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[tsq]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=1421</guid>

					<description><![CDATA[<p>Today I&#8217;ve encountered a vertical table in an SQL Database and I wanted to transform it to an horizontal one. A vertical table is described as an EAV model. Imagine you have this table CREATE TABLE VerticalTable ( Id int, Att_Id varchar(50), Att_Value varchar(50) ) INSERT INTO VerticalTable SELECT 1, 'FirstName', 'John' UNION ALL SELECT [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2016/10/27/converting-a-vertical-table-to-an-horizontal-table-in-sql-server/">Converting a Vertical Table to an Horizontal Table in SQL Server</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today I&#8217;ve encountered a vertical table in an SQL Database and I wanted to transform it to an horizontal one. A vertical table is described as an <a href="https://goo.gl/5aym8G" target="_blank" rel="noopener">EAV model</a>.</p>
<p>Imagine you have this table</p>
<pre class="brush: sql; title: ; notranslate">

CREATE TABLE VerticalTable
(
Id int,
Att_Id varchar(50),
Att_Value varchar(50)
)

INSERT INTO VerticalTable
SELECT 1, 'FirstName', 'John' UNION ALL
SELECT 1, 'LastName', 'Smith' UNION ALL
SELECT 1, 'Email', 'john.smith@dummy.com' UNION ALL
SELECT 2, 'FirstName', 'Jack' UNION ALL
SELECT 2, 'LastName', 'Daniels' UNION ALL
SELECT 2, 'Email', 'jack.daniels@dummy.com'

</pre>
<p>If you run</p>
<pre class="brush: sql; title: ; notranslate">

SELECT * FROM VerticalTable

</pre>
<p>you get this</p>
<table class="sqloutput">
<tbody>
<tr>
<th></th>
<th>Id</th>
<th>Att_Id</th>
<th>Att_Value</th>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>FirstName</td>
<td>John</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>LastName</td>
<td>Smith</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>Email</td>
<td>john.smith@dummy.com</td>
</tr>
<tr>
<td>4</td>
<td>2</td>
<td>FirstName</td>
<td>Jack</td>
</tr>
<tr>
<td>5</td>
<td>2</td>
<td>LastName</td>
<td>Daniels</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
<td>Email</td>
<td>jack.daniels@dummy.com</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>To convert this into an horizontal table I&#8217;m going to use <a href="https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx" target="_blank" rel="noopener">PIVOT</a>.</p>
<pre class="brush: sql; title: ; notranslate">

SELECT &#x5B;Id], &#x5B;FirstName], &#x5B;LastName], &#x5B;Email] 
FROM
(
 SELECT Id, Att_Id, Att_Value FROM VerticalTable
) as source
PIVOT
(
 MAX(Att_Value) FOR Att_Id IN (&#x5B;FirstName], &#x5B;LastName], &#x5B;Email])
) as target

</pre>
<p>And I will get this</p>
<table class="sqloutput">
<tbody>
<tr>
<th></th>
<th>Id</th>
<th>FirstName</th>
<th>LastName</th>
<th>Email</th>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>John</td>
<td>Smith</td>
<td>john.smith@dummy.com</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>Jack</td>
<td>Daniels</td>
<td>jack.daniels@dummy.com</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>You can find the code <a href="http://rextester.com/NSKR13741" target="_blank" rel="noopener">here</a>.</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2016/10/27/converting-a-vertical-table-to-an-horizontal-table-in-sql-server/">Converting a Vertical Table to an Horizontal Table in SQL Server</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2016/10/27/converting-a-vertical-table-to-an-horizontal-table-in-sql-server/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>SQL Persisted Computed Column ANSI_NULLS</title>
		<link>https://blogit.create.pt/ricardocosta/2015/11/25/sql-persisted-computed-column-ansi_nulls/</link>
					<comments>https://blogit.create.pt/ricardocosta/2015/11/25/sql-persisted-computed-column-ansi_nulls/#respond</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Wed, 25 Nov 2015 14:06:15 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=1081</guid>

					<description><![CDATA[<p>I had to recreate a table in SQL Server just because it was created with ANSI_NULLS ON Here you can check the requirements to create a persisted  computed column on SQL Server. &#8220;&#8230;the SET options in the following table must be set to the values shown in the Required value column&#8230;&#8221; SET options Required value [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2015/11/25/sql-persisted-computed-column-ansi_nulls/">SQL Persisted Computed Column ANSI_NULLS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I had to recreate a table in SQL Server just because it was created with ANSI_NULLS ON</p>
<p><a title="SET Options That Affect Results" href="https://msdn.microsoft.com/en-us/library/ms175088.aspx" target="_blank">Here</a> you can check the requirements to create a persisted  computed column on SQL Server.</p>
<p><em>&#8220;&#8230;the SET options in the following table must be set to the values shown in the Required value column&#8230;&#8221;</em></p>
<table>
<tbody>
<tr>
<th>SET options</th>
<th>Required value</th>
<th>Default server value</th>
<th>Default</p>
<p>OLE DB and ODBC value</th>
<th>Default</p>
<p>DB-Library value</th>
</tr>
<tr>
<td>ANSI_NULLS</td>
<td>ON</td>
<td>OFF</td>
<td>ON</td>
<td>OFF</td>
</tr>
<tr>
<td>ANSI_PADDING</td>
<td>ON</td>
<td>ON</td>
<td>ON</td>
<td>OFF</td>
</tr>
<tr>
<td>ANSI_WARNINGS*</td>
<td>ON</td>
<td>OFF</td>
<td>ON</td>
<td>OFF</td>
</tr>
<tr>
<td>ARITHABORT</td>
<td>ON</td>
<td>ON</td>
<td>OFF</td>
<td>OFF</td>
</tr>
<tr>
<td>CONCAT_NULL_YIELDS_NULL</td>
<td>ON</td>
<td>OFF</td>
<td>ON</td>
<td>OFF</td>
</tr>
<tr>
<td>NUMERIC_ROUNDABORT</td>
<td>OFF</td>
<td>OFF</td>
<td>OFF</td>
<td>OFF</td>
</tr>
<tr>
<td>QUOTED_IDENTIFIER</td>
<td>ON</td>
<td>OFF</td>
<td>ON</td>
<td>OFF</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2015/11/25/sql-persisted-computed-column-ansi_nulls/">SQL Persisted Computed Column ANSI_NULLS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2015/11/25/sql-persisted-computed-column-ansi_nulls/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Access the Previous Row and Next Row value in SELECT statement?</title>
		<link>https://blogit.create.pt/ricardocosta/2014/11/07/how-to-access-the-previous-row-and-next-row-value-in-select-statement/</link>
					<comments>https://blogit.create.pt/ricardocosta/2014/11/07/how-to-access-the-previous-row-and-next-row-value-in-select-statement/#respond</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Fri, 07 Nov 2014 11:09:37 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sql]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=741</guid>

					<description><![CDATA[<p>LAG &#8211; http://msdn.microsoft.com/en-us/library/hh231256.aspx USE AdventureWorks2012; GO SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota FROM Sales.SalesPersonQuotaHistory WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006'); LEAD &#8211; http://msdn.microsoft.com/en-us/library/hh213125.aspx USE AdventureWorks2012; GO SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, LEAD(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS NextQuota FROM Sales.SalesPersonQuotaHistory WHERE [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/11/07/how-to-access-the-previous-row-and-next-row-value-in-select-statement/">How to Access the Previous Row and Next Row value in SELECT statement?</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>LAG</strong> &#8211; <a id="x_lnk563653" href="http://msdn.microsoft.com/en-us/library/hh231256.aspx" target="_blank"></a><a id="x_lnk618706" title="http://msdn.microsoft.com/en-us/library/hh231256.aspx&lt;br /&gt;&lt;br /&gt;
Ctrl+click or tap to follow link" href="http://msdn.microsoft.com/en-us/library/hh231256.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/hh231256.aspx</a></p>
<pre>USE AdventureWorks2012;
GO
SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, 
       LAG(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS PreviousQuota
FROM Sales.SalesPersonQuotaHistory
WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006');</pre>
<p><strong>LEAD</strong> &#8211; <a id="x_lnk627900" href="http://msdn.microsoft.com/en-us/library/hh213125.aspx" target="_blank"></a><a id="x_lnk774047" href="http://msdn.microsoft.com/en-us/library/hh213125.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/hh213125.aspx</a></p>
<pre>USE AdventureWorks2012;
GO
SELECT BusinessEntityID, YEAR(QuotaDate) AS SalesYear, SalesQuota AS CurrentQuota, 
    LEAD(SalesQuota, 1,0) OVER (ORDER BY YEAR(QuotaDate)) AS NextQuota
FROM Sales.SalesPersonQuotaHistory
WHERE BusinessEntityID = 275 and YEAR(QuotaDate) IN ('2005','2006');</pre>
<p>SQL SERVER 2012 and 2014</p>
<p>&nbsp;</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/11/07/how-to-access-the-previous-row-and-next-row-value-in-select-statement/">How to Access the Previous Row and Next Row value in SELECT statement?</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2014/11/07/how-to-access-the-previous-row-and-next-row-value-in-select-statement/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Strange behavior with &#8220;Merge Join&#8221; in SSIS</title>
		<link>https://blogit.create.pt/ricardocosta/2014/10/24/strange-behavior-with-merge-join-in-ssis/</link>
					<comments>https://blogit.create.pt/ricardocosta/2014/10/24/strange-behavior-with-merge-join-in-ssis/#respond</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Fri, 24 Oct 2014 10:04:36 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SSIS]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=691</guid>

					<description><![CDATA[<p>If the datasources of the Merge Join block in SSIS aren&#8217;t sorted the merge will not work correctly. Strange behavior will occur if the datasources aren&#8217;t sorted equal by the same key. http://msdn.microsoft.com/en-us/library/ms141775.aspx &#8220;The Merge Join Transformation requires sorted data for its inputs.&#8221; http://msdn.microsoft.com/en-us/library/ms137653.aspx</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/10/24/strange-behavior-with-merge-join-in-ssis/">Strange behavior with &#8220;Merge Join&#8221; in SSIS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If the datasources of the Merge Join block in SSIS aren&#8217;t sorted the merge will not work correctly.</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2014/10/mergejoin.png"><img decoding="async" class="alignnone size-full wp-image-701" src="http://blogit-create.com/wp-content/uploads/2014/10/mergejoin.png" alt="Merge Join" width="148" height="62" /></a></p>
<p>Strange behavior will occur if the datasources aren&#8217;t sorted equal by the same key.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms141775.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms141775.aspx</a></p>
<p><em>&#8220;The Merge Join Transformation requires sorted data for its inputs.&#8221;</em></p>
<p><a title="Sort Data for the Merge and Merge Join Transformation" href="http://msdn.microsoft.com/en-us/library/ms137653.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms137653.aspx</a></p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/10/24/strange-behavior-with-merge-join-in-ssis/">Strange behavior with &#8220;Merge Join&#8221; in SSIS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2014/10/24/strange-behavior-with-merge-join-in-ssis/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SharePoint Tunning Session</title>
		<link>https://blogit.create.pt/miguelisidoro/2014/10/14/sharepoint-tunning-session/</link>
					<comments>https://blogit.create.pt/miguelisidoro/2014/10/14/sharepoint-tunning-session/#respond</comments>
		
		<dc:creator><![CDATA[Miguel Isidoro]]></dc:creator>
		<pubDate>Tue, 14 Oct 2014 21:54:32 +0000</pubDate>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[SQL Server]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/miguelisidoro/?p=1191</guid>

					<description><![CDATA[<p>Last week I delivered a session at SharePoint Portuguese Community 36th event. My session was entitled SharePoint Tunning, focused on techniques used to improve the performance of a SharePoint farm. The main topics of the session were: SQL Server performance tips (most of the presentation, since performance in SharePoint is guaranteed mainly at SQL Server level) SharePoint farm performance tips SharePoint development tips You [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/miguelisidoro/2014/10/14/sharepoint-tunning-session/">SharePoint Tunning Session</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Last week I delivered a session at <strong><a href="http://www.sharepointpt.org/archive/2014/10/09/spugptmeeting36.aspx" target="_blank" rel="noopener">SharePoint Portuguese Community 36th event</a></strong>.</p>
<p>My session was entitled <strong>SharePoint Tunning</strong>, focused on techniques used to improve the performance of a SharePoint farm. The main topics of the session were:</p>
<ul>
<li>SQL Server performance tips (most of the presentation, since performance in SharePoint is guaranteed mainly at SQL Server level)</li>
<li>SharePoint farm performance tips</li>
<li>SharePoint development tips</li>
</ul>
<p>You can find the slide deck <strong><a href="http://www.slideshare.net/miguellopesisidoro/20141011-spug-pt-sharepoint-tunning" target="_blank" rel="noopener">here</a></strong>. I hope you understand Portuguese since the slide deck is in my mother language :).</p>
<p>Related Links:</p>
<ul>
<li><a href="http://www.sharepointpt.org/" target="_blank" rel="noopener">Portuguese SharePoint Community web site</a></li>
<li><a href="http://www.slideshare.net/miguellopesisidoro" target="_blank" rel="noopener">My SlideShare web site</a></li>
<li><a href="http://www.create.pt/" target="_blank" rel="noopener"><strong>|create|it| </strong>web site</a></li>
</ul>
<p>If you are a SharePoint administrator or a SharePoint developer who wants to learn more about how to install a SharePoint farm in an automated way using PowerShell, I invite you to click <a href="https://blogit.create.pt////miguelisidoro/2018/07/28/how-to-install-a-sharepoint-2016-farm-using-powershell-and-autospinstaller-part-1/" target="_blank" rel="noopener">here</a> and <a href="https://blogit.create.pt////miguelisidoro/2018/07/28/how-to-install-a-sharepoint-2016-farm-using-powershell-and-autospinstaller-part-2/" target="_blank" rel="noopener">here</a>. The articles use AutoSPInstaller with a SharePoint 2016 farm but AutoSPInstaller support for SharePoint 2019 was already announced!</p>
<p>If you are new to SharePoint and Office 365 and want to learn all about it, take a look at these <a href="https://blogit.create.pt////miguelisidoro/2018/10/17/sharepoint-and-office-365-learning-resources/" target="_blank" rel="noopener">learning resources</a>.</p>
<p><strong>UPDATE 01/11/2018:</strong></p>
<p>If you or your customers are not ready to move entirely to the Cloud and Office 365, a hybrid scenario could be an interesting scenario and SharePoint 2019 RTM was recently announced with improved hybrid support! To learn all about SharePoint 2019 and all its features, click <a href="https://blogit.create.pt////miguelisidoro/2018/11/01/meet-the-new-modern-sharepoint-server-sharepoint-2019-rtm-is-here/" target="_blank" rel="noopener">here</a>.</p>
<p><strong>UPDATE 21/11/2018:</strong></p>
<p>If you want to know all about the latest SharePoint and Office 365 announcements from Ignite and some more recent announcements, including Microsoft Search, What’s New to Build a Modern Intranet with SharePoint in Office 365, Deeper Integration between Microsoft Teams and SharePoint and the latest news on SharePoint development, click <a href="https://blogit.create.pt////miguelisidoro/2018/11/21/whats-new-for-sharepoint-and-office-365-after-microsoft-ignite-2018/" target="_blank" rel="noopener">here</a>.</p>
<p>Happy SharePointing!</p>
<p>The post <a href="https://blogit.create.pt/miguelisidoro/2014/10/14/sharepoint-tunning-session/">SharePoint Tunning Session</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/miguelisidoro/2014/10/14/sharepoint-tunning-session/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
