<?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: Tácio Alves</title>
    <description>The latest articles on DEV Community by Tácio Alves (@tacioalves).</description>
    <link>https://dev.to/tacioalves</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%2F3974031%2Ff724be48-4063-422d-8c74-d8fc8b26a47b.png</url>
      <title>DEV Community: Tácio Alves</title>
      <link>https://dev.to/tacioalves</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tacioalves"/>
    <language>en</language>
    <item>
      <title>T-SQL patterns that break when you migrate SQL Server to PostgreSQL (and where they hide in Java/C#)</title>
      <dc:creator>Tácio Alves</dc:creator>
      <pubDate>Mon, 08 Jun 2026 15:41:42 +0000</pubDate>
      <link>https://dev.to/tacioalves/t-sql-patterns-that-break-when-you-migrate-sql-server-to-postgresql-and-where-they-hide-in-javac-jf1</link>
      <guid>https://dev.to/tacioalves/t-sql-patterns-that-break-when-you-migrate-sql-server-to-postgresql-and-where-they-hide-in-javac-jf1</guid>
      <description>&lt;p&gt;Database migrations look "done" until Monday morning.&lt;/p&gt;

&lt;p&gt;The stored procedures are converted. The schema is on PostgreSQL. Then the order API fails — because nobody inventoried &lt;code&gt;nativeQuery = true&lt;/code&gt; in Spring or &lt;code&gt;FromSqlRaw&lt;/code&gt; in EF Core.&lt;/p&gt;

&lt;p&gt;Here are five patterns that survive the DBA's &lt;code&gt;.sql&lt;/code&gt; bundle but break in production:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. SELECT TOP
&lt;/h2&gt;

&lt;p&gt;PostgreSQL uses &lt;code&gt;LIMIT&lt;/code&gt;. Easy to miss inside a 40-character &lt;code&gt;@Query&lt;/code&gt; string.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. GETDATE() / SYSDATETIME()
&lt;/h2&gt;

&lt;p&gt;Becomes &lt;code&gt;NOW()&lt;/code&gt; or &lt;code&gt;CURRENT_TIMESTAMP&lt;/code&gt; — but only if you find every occurrence in application code.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. ISNULL()
&lt;/h2&gt;

&lt;p&gt;PostgreSQL prefers &lt;code&gt;COALESCE&lt;/code&gt;. Sounds trivial until it's buried in a Dapper query.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. TRY/CATCH in batches
&lt;/h2&gt;

&lt;p&gt;No direct equivalent in PL/pgSQL the same way. Often lives in dynamic SQL built in C#.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. MERGE / OUTPUT clauses
&lt;/h2&gt;

&lt;p&gt;Common in SQL Server scripts &lt;strong&gt;and&lt;/strong&gt; in hand-written repository methods — rarely in the same migration spreadsheet.&lt;/p&gt;




&lt;h2&gt;
  
  
  The inventory problem
&lt;/h2&gt;

&lt;p&gt;DBA-owned: &lt;code&gt;.sql&lt;/code&gt; files, procedures, schema scripts.&lt;/p&gt;

&lt;p&gt;App-owned: &lt;code&gt;.java&lt;/code&gt;, &lt;code&gt;.cs&lt;/code&gt;, &lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.py&lt;/code&gt;, &lt;code&gt;.php&lt;/code&gt; with embedded T-SQL.&lt;/p&gt;

&lt;p&gt;Two inventories. One cutover date.&lt;/p&gt;




&lt;h2&gt;
  
  
  What we do before cutover
&lt;/h2&gt;

&lt;p&gt;Scan application repos for embedded SQL → file + line + risk report → human review on flagged lines.&lt;/p&gt;

&lt;p&gt;I built &lt;a href="https://sqlshifter.com/audit?utm_source=devto&amp;amp;utm_campaign=patterns" rel="noopener noreferrer"&gt;SQLShifter&lt;/a&gt; for this after one too many post-migration fire drills:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;~95% accuracy on common SS↔PG patterns (&lt;a href="https://sqlshifter.com/accuracy" rel="noopener noreferrer"&gt;methodology&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Free: 2 full analyses/month, 3 files&lt;/li&gt;
&lt;li&gt;Files not stored on server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not a replacement for migration planning — a pre-flight check.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What's the worst post-migration surprise you've seen outside the official script bundle?&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>backend</category>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
