<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhinav Gupta</title>
    <description>The latest articles on DEV Community by Abhinav Gupta (@abhinavgupta1997).</description>
    <link>https://dev.to/abhinavgupta1997</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F678772%2F38fcd771-e255-462c-8964-9689d74981ab.jpg</url>
      <title>DEV Community: Abhinav Gupta</title>
      <link>https://dev.to/abhinavgupta1997</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhinavgupta1997"/>
    <language>en</language>
    <item>
      <title>Migrating Database from SQL Server(MSSQL) to PostgreSQL</title>
      <dc:creator>Abhinav Gupta</dc:creator>
      <pubDate>Thu, 12 Aug 2021 13:09:21 +0000</pubDate>
      <link>https://dev.to/abhinavgupta1997/migrating-database-from-sql-server-mssql-to-postgresql-1mje</link>
      <guid>https://dev.to/abhinavgupta1997/migrating-database-from-sql-server-mssql-to-postgresql-1mje</guid>
      <description>&lt;p&gt;Since developers are preferring open-source databases now-a-days, PostgreSQL can be a good option where you can migrate your database. Open-source databases can be beneficial for developers and enterprises in many terms.&lt;/p&gt;

&lt;p&gt;While this post is about migrating databases specifically from SQL Server(MSSQL) to PostgreSQL, I won't talk much about the differences between them. To see the differences between them, &lt;a href="https://www.enterprisedb.com/blog/microsoft-sql-server-mssql-vs-postgresql-comparison-details-what-differences" rel="noopener noreferrer"&gt;click here&lt;/a&gt;. Also, the steps mentioned in the article is for Windows 10.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  How to Migrate?
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are different ways through which you can migrate your database from MSSQL to Postgres. It can be done manually by creating same database schema in Postgres as you have in MSSQL or you can use any tool that migrates the data automatically.&lt;/p&gt;

&lt;p&gt;Migrating the database schema manually can be a way. You can generate scripts in MSSQL Server Management Studio and execute those scripts in Postgres' &lt;strong&gt;SQL Shell&lt;/strong&gt; or &lt;strong&gt;PgAdmin&lt;/strong&gt;. This will create the database schema in Postgres and then you'll have to export the data but there can be some errors produced due to different datatype compatibility in both MSSQL and Postgres.&lt;/p&gt;

&lt;p&gt;Using a migrating tool can save much time and work as it will generate the scripts itself and create the schema in Postgres. There are different migration tools available:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;EnterpriseDB Migration Toolkit&lt;/li&gt;
&lt;li&gt;Sqlserver2pgsql&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Migrating Database Schema manually
&lt;/h3&gt;

&lt;p&gt;To migrate the database manually, you can generate scripts for either a table or a complete database and execute those scripts in PostgreSQL .&lt;/p&gt;

&lt;p&gt;To generate scripts for a database in SQL Server, follow the steps mentioned below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Open MS SQL Server Management Studio. Connect to the server. Go to the database that needs to be migrated. &lt;strong&gt;Right click on the database &amp;gt; Tasks &amp;gt; Generate Scripts&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcu28urmu420xs8hd13vh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcu28urmu420xs8hd13vh.png" alt="SSMS Generate Scripts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; &lt;strong&gt;Choose the objects&lt;/strong&gt; for which the scripts have to be generated. You can either choose to script the entire database and all the database objects or specific database objects.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx2rmaw8s0v19ywn3qpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx2rmaw8s0v19ywn3qpr.png" alt="Choose database objects to script"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; &lt;strong&gt;Set the Scripting Option&lt;/strong&gt;. You can open the scripts in a new query window or you can generate the scripts in a single file or one object script in one file.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswkip7nqmemk0r9u7aef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fswkip7nqmemk0r9u7aef.png" alt="Scripting options"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; &lt;strong&gt;Review your objects and settings&lt;/strong&gt; and &lt;strong&gt;Finish&lt;/strong&gt;. The scripts will be generated.&lt;/p&gt;

&lt;p&gt;After the scripts are generated, execute those scripts in either PostgreSQL' &lt;strong&gt;SQL Shell&lt;/strong&gt; or &lt;strong&gt;PgAdmin&lt;/strong&gt;. The PostgreSQL database schema will be generated.&lt;/p&gt;
&lt;h3&gt;
  
  
  Migrating Database using Migration Toolkit
&lt;/h3&gt;

&lt;p&gt;Migrating database by generating scripts can be time consuming. Using a migration tool can save a lot of time and effort. There are some migration tools available which can be used to migrate the database easily. Here, I will use &lt;a href="https://www.enterprisedb.com/products/oracle-to-postgresql-migration-toolkit-move-from" rel="noopener noreferrer"&gt;EnterpriseDB's Migration Toolkit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can either download EnterpriseDB's Migration Toolkit from their &lt;a href="https://www.enterprisedb.com/products/oracle-to-postgresql-migration-toolkit-move-from" rel="noopener noreferrer"&gt;website&lt;/a&gt; or you can open &lt;strong&gt;Application Stack Builder&lt;/strong&gt; on your system and install it.&lt;/p&gt;
&lt;h4&gt;
  
  
  Steps to install EnterpriseDB's Migration Toolkit
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Open the &lt;strong&gt;Application Stack Builder&lt;/strong&gt;. Stack Builder is downloaded when you download PostgreSQL.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8txevbnu1x9zw7izb7f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8txevbnu1x9zw7izb7f.jpg" alt="Stack Builder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Select the PostgreSQL server where you want to install the Migration Toolkit. Make sure you're connected to the Internet.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsbdpkjujy55ak63bxtc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsbdpkjujy55ak63bxtc.png" alt="Stack Builder Welcome Wizard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; The wizard will show the applications that can be installed. Go to &lt;strong&gt;Categories &amp;gt; Registration-required and trial products &amp;gt; EnterpriseDB Tools&lt;/strong&gt;. Check the &lt;strong&gt;Migration Toolkit&lt;/strong&gt; and click on &lt;strong&gt;Next&lt;/strong&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9a3rdvlco3lzkf76ri2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr9a3rdvlco3lzkf76ri2.png" alt="Migration Toolkit to be installed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; You'll be asked to Select you &lt;strong&gt;Download directory&lt;/strong&gt;. Select your desired folder where you want to download and click on &lt;strong&gt;Next&lt;/strong&gt;. The Migration Toolkit will be downloaded and you'll be asked to install it. After installing, the Migration Toolkit is ready to be used.&lt;/p&gt;
&lt;h4&gt;
  
  
  Building the toolkit.properties File
&lt;/h4&gt;

&lt;p&gt;The &lt;strong&gt;toolkit.properties&lt;/strong&gt; file is needed to provide the configuration and connection information of the source and target databases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Open the toolkit.properties file. On Windows, the file will be located in:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C:\Program Files\edb\mtk\etc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Modify the file with any editor of your choice. I personally prefer VS Code. The file should contain the following information:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SRC_DB_URL&lt;/em&gt; : specifies the connection information of the source database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SRC_DB_USER&lt;/em&gt; : specifies the username for the source database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;SRC_DB_PASSWORD&lt;/em&gt; : specifies the password for the source database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;TARGET_DB_URL&lt;/em&gt; : specifies the connection information of the target database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;TARGET_DB_USER&lt;/em&gt; : specifies the username for the target database.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;TARGET_DB_PASSWORD&lt;/em&gt; : specifies the password for the target database.&lt;/p&gt;

&lt;p&gt;The URL of the database must be in the given format:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{TARGET_DB_URL|SRC_DB_URL}=jdbc:edb://host:port/database_id&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here's a sample toolkit.properties file with SQL Server as source database and PostgreSQL as target database.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5r1v87arrgv4jkq2zos.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5r1v87arrgv4jkq2zos.png" alt="toolkit.properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For additional information on configuring the toolkit.properties file and for migrating databases other than SQL Server, refer &lt;a href="https://www.enterprisedb.com/edb-docs/d/edb-postgres-migration-toolkit/user-guides/user-guide/53.0.2/building_toolkit.properties_file.html#defining-a-postgresql-url" rel="noopener noreferrer"&gt;Building the toolkit.properties File&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Invoking the Migration Toolkit
&lt;/h4&gt;

&lt;p&gt;After the toolkit.properties file is configured, we are ready to migrate the database using Migration Toolkit. We will invoke the Migration Toolkit using the executable &lt;em&gt;runMTK.bat&lt;/em&gt; file. On Windows, you can find the executable file in:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;C:\Program Files\edb\mtk\bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To invoke the Migration Toolkit, open the command line and navigate to the executable file and invoke the following command:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;gt; .\runMTK.bat -sourcedbtype sqlserver -targetdbtype postgres [options, …] &amp;lt;schema_name&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;You can migrate multiple schemas at a time by mentioning the schema names using comma-delimited list such as:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;gt; .\runMTK.bat -sourcedbtype sqlserver -targetdbtype postgres [options, …] &amp;lt;schema_name1&amp;gt;,&amp;lt;schema_name2&amp;gt;,&amp;lt;schema_name3&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;If you don't mention the &lt;code&gt;-sourcetype&lt;/code&gt; and &lt;code&gt;-targettype&lt;/code&gt; parameter in the command, by default the Migration Toolkit expects the source database to be Oracle and the target database to be EDB Postgres Advanced Server.&lt;/p&gt;

&lt;p&gt;After invoking the Migration Toolkit, the database schema along with the data will be migrated from SQL Server to PostgreSQL. You can verify the tables and its data in Postgres.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  Things to keep in mind while migrating
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; Before migrating databases, you must know the syntax differences between your source and target database. I this case, its MSSQL and Postgres.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Datatype Mismatch:&lt;/strong&gt; Both SQL Server and PostgreSQL has different datatypes.&lt;/p&gt;

&lt;p&gt;While migrating manually, you have to take care with it. You can write scripts to convert the datatypes of SQL Server to desired PostgreSQL datatypes or you can manually convert the datatypes after generating the &lt;strong&gt;CREATE&lt;/strong&gt; scripts and before executing it in Postgres.&lt;/p&gt;

&lt;p&gt;Using &lt;em&gt;Migration Toolkit&lt;/em&gt;, the datatypes will be converted by the toolkit. But there can be some errors while inserting the data by it. Since Migration Toolkit migrates the schema along with the data, after converting the datatypes, while inserting the data, some data in specific column with specific datatype will not be converted to desired datatype by the Migration Toolkit.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;e.g.-&lt;/em&gt; We don't have &lt;strong&gt;boolean&lt;/strong&gt; datatype in SQL Server but we have &lt;strong&gt;boolean&lt;/strong&gt; in PostgreSQL. Boolean data is stored as &lt;strong&gt;bit&lt;/strong&gt; datatype in SQL Server and the data will be inserted as &lt;strong&gt;1&lt;/strong&gt; for 'true' and &lt;strong&gt;0&lt;/strong&gt; for 'false'. The Migration Toolkit will convert the &lt;strong&gt;bit&lt;/strong&gt; datatype to &lt;strong&gt;boolean&lt;/strong&gt; datatype but while inserting 1 and 0 in that, it will throw error as the PostgreSQL expects boolean data to be either &lt;strong&gt;true&lt;/strong&gt; or &lt;strong&gt;false&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;To fix this, you can write scripts to convert &lt;strong&gt;1&lt;/strong&gt; to &lt;strong&gt;true&lt;/strong&gt; and &lt;strong&gt;0&lt;/strong&gt; to &lt;strong&gt;false&lt;/strong&gt; using &lt;strong&gt;CASE&lt;/strong&gt; statements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;System-defined Functions Mismatch:&lt;/strong&gt; MSSQL and PostgreSQL provide different functions for same thing which needs to be taken care of while migrating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e.g.-&lt;/strong&gt; We have &lt;strong&gt;GETDATE()&lt;/strong&gt; to get the current date in MSSQL but in PostgreSQL, we have &lt;strong&gt;NOW()&lt;/strong&gt; for that.&lt;/p&gt;

&lt;p&gt;To get the UTC date, we have &lt;strong&gt;GETUTCDATE()&lt;/strong&gt; in MSSQL but in Postgres we need to write the following query:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;NOW&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;AT&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt; &lt;span class="k"&gt;zone&lt;/span&gt; &lt;span class="s1"&gt;'utc'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;We have &lt;strong&gt;NEWID()&lt;/strong&gt; in MSSQL that creates a unique value of type uniqueidentifier but in Postgres, we have &lt;strong&gt;uuid_generate_v4()&lt;/strong&gt; for this which comes as extension.&lt;/p&gt;

&lt;p&gt;We have &lt;strong&gt;ISNULL(expression, value)&lt;/strong&gt; that returns a specified value if the expression is NULL in MSSQL but in Postgres, we have &lt;strong&gt;COALESCE(expression, value)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you want to use functions with the same name as MSSQL in Postgres, you can create a user-defined function with the same name and write the Postgres' equivalent function query inside it.&lt;/p&gt;

&lt;p&gt;There are many other functions that are different in both which needs to be taken care of.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case-sensitivity:&lt;/strong&gt; In Postgres, if we mention any tablename or columnname inside double quotes(""), it is taken as case-sensitive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e.g.-&lt;/strong&gt; ```sql&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;SELECT firstname FROM candidate;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
is equivalent to 

```sql


SELECT FirstName FROM Candidate;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;but both are different to&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="nv"&gt;"FirstName"&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="nv"&gt;"Candidate"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;String Concatenation:&lt;/strong&gt; When we try to concatenate data from two or more columns, in MSSQL, we can write the query as:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;lastname&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;candidatename&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But in Postgres, we write as:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;

&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;' '&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;lastname&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;candidatename&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Stored Procedures:&lt;/strong&gt; The stored procedures in Postgres doesn't work same as in MSSQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e.g.-&lt;/strong&gt; In MSSQL stored procedure, if we want to return a query that contains multiple columns, we will just write the query inside the procedure but in Postgres, we have to write all the &lt;strong&gt;in&lt;/strong&gt; and &lt;strong&gt;out&lt;/strong&gt; parameters.&lt;/p&gt;

&lt;p&gt;We can return multiple records through stored procedures in MSSQL, but in Postgres, we cannot return multiple records using stored procedure. To do this, we have to create a function with return type as &lt;strong&gt;TABLE&lt;/strong&gt; and write the query inside it.&lt;/p&gt;

&lt;p&gt;There are other incompatibilities too which are not mentioned in this article. The mentioned are the basic things which we need to keep in mind while migrating.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;
&lt;/blockquote&gt;

&lt;p&gt;Migrating to PostgreSQL can be beneficial as it is open source and has complex datatypes but MSSQL has its own features. Choosing between the databases completely depends on the use case. If migrating to PostgreSQL, we have to take care of the datatypes, syntax and other things which is mentioned in the article while migrating.&lt;/p&gt;




&lt;blockquote&gt;
&lt;h2&gt;
  
  
  If you have reached this far, hopefully, this quick overview helps you ease migration of your databases. Thank You for giving this a read!!
&lt;/h2&gt;
&lt;/blockquote&gt;

</description>
      <category>postgres</category>
    </item>
  </channel>
</rss>
