AI Revamp: Migrating MySQL → MS SQL Express | AI 重構:從 MySQL 搬家到 MS SQL Express

[27 Mar 2026]

Preface: A Compliment from AI | 前言:AI 的一句話

When I handed my draft to AI for polishing, it surprised me with a line:
“While everyone is busy praising AI, you’re writing about how to use it correctly!”
That made me laugh — and reassured me that I’m on the right path.

把初稿交給 AI 潤飾,AI 居然回我一句:「大家都在吹捧 AI,你卻在寫怎麼正確用 AI!」
這句話讓我笑出來 —— 原來我真的在走一條不一樣的路。

Tools used in this revamp project: free Microsoft Copilot, free xAI Grok | Revamp project 使用 AI:Free Microsoft Copilot、Free xAI Grok

這次重構專案用到的工具:免費版 Microsoft Copilot、免費版 xAI Grok

Story: Wrestling with Legacy Code | 引言: 舊系統的「怪胎」挑戰

Every engineer knows the pain: legacy systems are full of quirks. Stored procedures written twenty years ago in old MySQL syntax are fragile, undocumented, and prone to errors.

工程師都懂,舊系統就是一堆怪胎。二十年前的 MySQL stored procedures,語法老舊、文件缺乏,改一行就爆一堆錯。

At first, I naively asked Copilot to tweak a few SQL statements. The result? A flood of syntax errors. That’s when it hit me — AI struggles with “ancient dialects” because there’s little reference material available.

我一開始天真地用 Copilot 改幾段 SQL,結果滿屏 syntax error。這時候我才意識到:AI 在「古董語法」面前也會抓狂。


So instead of patching, I decided to migrate. I installed MS SQL Express — a free database with a 10GB limit — and asked Copilot to rewrite the old MySQL stored procedures into MS SQL syntax. This time, AI delivered cleanly and efficiently.

既然修補困難,不如直接搬家。於是我安裝了 MS SQL Express —— 免費、10GB 容量 —— 然後請 Copilot 把舊 MySQL stored procedures 改寫成 MS SQL。這次,AI 表現超穩,翻譯得乾淨俐落。

Case Study: MS SQL Express Pitfalls and Gains | MS SQL Express 的坑與收穫


MS SQL Server 會自動設定 port,但 Express 版沒有。第一次 telnet 測試完全怪怪的,花了不少時間才搞定。不過只要設定過一次,後面就輕鬆了。

  1. Port Configuration | Port 設定
    MS SQL Server auto‑assigns ports, but Express doesn’t. My first telnet test felt wrong, and it took time to configure properly. Once done, though, future setups were straightforward.

    MS SQL Server 會自動設定 port,但 Express 版沒有。第一次 telnet 測試完全怪怪的,花了不少時間才搞定。不過只要設定過一次,後面就輕鬆了。
  2. Database Email Sending | Database 發送 Email
    In MS SQL Server, you can configure database email either through the GUI or with scripts.
    In MS SQL Express, however, you must rely on scripts.Personally, I find this better — scripts are reusable across projects and improve portability.

    在 MS SQL Server 中,可以透過 GUI 或 Script 來設定由資料庫發送 Email。
    而在 MS SQL Express 中,則必須使用 Script。
    我反而覺得這樣更好 —— 因為 Script 可以跨專案重用,提升了可移植性。

Cost Efficiency | 成本效益

  • Free 10GB capacity : sufficient for most small to mid‑sized projects.
  • 免費 10GB 容量:足以支撐大部分中小型專案。
  • Full functionality : covers everyday needs.
  • 功能完整:日常需求綽綽有餘。
  • AI‑assisted rewriting : accelerates modernization, saving the workforce.
  • 結合 AI 改寫:能快速翻新舊系統,節省大量人力成本。

AI’s Familiarity with Technology | AI 對技術的熟悉度

From experience, AI doesn’t always handle the latest technologies well. But for tools that have been around for at least two years — or evergreen ones like MS SQL Express — AI performs brilliantly. The abundance of documentation, tutorials, and community discussions gives AI a solid knowledge base to generate accurate syntax and solutions.

根據我的實戰經驗,AI 對最新技術未必有足夠的參考資料,容易出現錯誤或不完整的建議。相反,對於已經存在兩年以上的新技術,或是長青的技術(例如 MS SQL Express),AI 的效果特別好。這是因為這些技術在公開資料、社群討論和教學案例中已經累積了足夠的知識基礎,AI 能更準確地生成正確語法和解決方案。

MS SQL Express 的其他優點

除了上述的成本效益與 script 可重用性,MS SQL Express 還有一些值得一提的優點:

  • 與 Microsoft 生態系統整合:與 Visual Studio、.NET Framework、ASP.NET 等工具高度整合。
  • 升級路徑清晰:專案成長時,可順暢升級到 Standard 或 Enterprise 版本。
  • 安全性與維護:享有 Microsoft 定期的安全更新,保障系統穩定。
  • 學習資源豐富:SQL Server 是長青技術,社群與教學文章非常多。

Bonus Value from AI Rewriting | 進階紅利:AI 改寫帶來的額外價值

AI migration isn’t just translation — it adds unexpected value:

  • Automated Documentation: Old procedures often lack comments. AI rewrites with detailed annotations, creating human‑readable documentation.
  • Security Enhancements: Legacy SQL may contain vulnerabilities. AI applies modern standards, such as parameterized queries.
  • Performance Optimization: Inefficient cursors and joins are replaced with modern techniques like window functions.
  • Unit Test Generation: AI can produce SQL unit tests to ensure input/output consistency between old and new systems.

AI 改寫帶來的額外紅利

  • 自動加註解:舊程式沒文件,AI 改寫時會補上邏輯說明。
  • 安全升級:舊 SQL 可能有 Injection,AI 改寫時會自動套用參數化查詢。
  • 效能優化:AI 會把低效的 Cursor 換成 Window Functions。
  • 單元測試:AI 能生成 SQL Unit Test,確保新舊系統一致。

Engineer’s Checklist: What Still Needs Attention | 工程師仍需注意的細節

Even with AI’s help, engineers must handle:

  • Environment setup: database permissions and firewall ports.
  • Connection strings: update across applications.
  • Client‑side adjustments: parameter types may change during migration.

工程師仍需注意的細節

  • 環境配置:權限、防火牆 Port。
  • 連線字串:全面更新。
  • 呼叫端:Data Type 改變時要同步修正。

Conclusion: From “Fixer” to “Architect” | 結語:從「修補者」到「建築師」

This MySQL → MS SQL Express migration taught me something important: facing legacy code doesn’t mean we must remain “fixers,” endlessly patching outdated syntax.

這次 MySQL → MS SQL Express 的經驗讓我明白:
工程師不必永遠當辛苦的「修補者」,守著舊語法苦苦掙扎。

With AI as our translator, we can migrate legacy systems into modern ecosystems at minimal cost. Yes, there are practical hurdles — port settings, data type adjustments — but the payoff is huge: stronger security, easier maintenance, and a longer technical lifecycle.

有了 AI,我們可以用低成本把舊系統搬到現代生態。雖然過程中還是有坑,但換來的是更好的安全性、可維護性,以及更長遠的技術生命週期。

AI isn’t just writing code; it’s helping us bridge decades of technical debt.

AI 不只是幫我們寫 Code,它是在幫我們跨越技術債的鴻溝。