Sybase → PostgreSQL: A Worked Example
A worked Sybase to PostgreSQL example: the shared T-SQL heritage with SQL Server, its own quirks, and where name-level introspection and dump-parsing take over.
Sybase ASE and Microsoft SQL Server descend from the same code base (Microsoft licensed it in 1989), which is the most useful fact for planning a Sybase migration: most of the SQL Server post applies directly. The T-SQL is cousins. Swordfish carries 60 Sybase rules — the thinnest catalog of the five, partly because so much overlaps with SQL Server and partly because Sybase deployments are rarer. Two honest notes up front: live-DB introspection here is name-level (Swordfish reads object names but not always full column/type detail over a live connection), so dump-file parsing is the more reliable path for Sybase; and you should expect to lean on the SQL Server findings for anything not Sybase-specific.
What carries over from SQL Server
TOP (SYB-005) → LIMIT. GETDATE() (SYB-009) → CURRENT_TIMESTAMP. ISNULL() (SYB-010) → COALESCE. Identity columns (SYB-S004, SYB-S005 for NUMERIC IDENTITY) → identity columns. DATETIME/SMALLDATETIME (SYB-S012, SYB-S013) → timestamp/timestamptz. Stored procedures, triggers, and error handling (SYB-P*: @@ERROR, PRINT, RAISERROR, cursors, EXECUTE IMMEDIATE) → PL/pgSQL. If you’ve read the SQL Server walkthrough, none of this is new.
The Sybase-specific findings
String concatenation with +: SYB-012 (high). Sybase overloads + for both arithmetic and string concatenation, so a + b is ambiguous out of context. In PostgreSQL, string concatenation is || and + is strictly arithmetic. The conversion isn’t just syntactic: a + that Sybase resolved as string concat (because the operands were char) must become ||, while a + on numerics stays. Get this wrong and you either get a type error (lucky) or silent numeric addition of values that were meant to be joined (not lucky). Review every + flagged.
ISNULL truncation behavior: SYB-BEH-003 (high). Like SQL Server’s ISNULL, Sybase’s coerces the replacement value to the first argument’s type and length, but Sybase’s truncation rules have their own edge cases. COALESCE doesn’t truncate the same way. Review ISNULL inside fixed-width string logic.
@@IDENTITY in procedures: SYB-BEH-002 (high). Same scope-crossing hazard as SQL Server’s. Replace with INSERT ... RETURNING or lastval(), and check for triggers on the target table. There’s also a SYB-020 rule for SCOPE_IDENTITY patterns.
#temp tables across statements: SYB-BEH-001 (medium/high). Sybase temp-table scoping and cross-statement visibility differ from PostgreSQL’s CREATE TEMP TABLE (which is session-scoped and dropped at session/transaction end depending on ON COMMIT). Procedures that create a #temp in one statement and rely on it in another need their temp-table lifecycle checked against PostgreSQL’s rules.
Datetime format quirks: SYB-BEH-004 (medium). Sybase accepts and emits datetime in formats PostgreSQL won’t parse the same way. Anywhere the application formats or parses datetime strings (rather than using bound parameters), confirm the format strings still produce the intended values.
Practical advice for Sybase
Because the catalog is thinner and live introspection is name-level, do two things differently for Sybase: export a schema dump and feed Swordfish the dump file rather than relying solely on a live connection, and read the SQL Server walkthrough alongside this one, since the T-SQL behavioral findings (LEN trailing spaces, TOP without ORDER BY, NOLOCK-style isolation hints) generally apply to Sybase too even where a dedicated Sybase rule doesn’t exist yet.
That closes the per-database series. Five source databases, one consistent loop: Swordfish tells you exactly what the source dialect is doing that PostgreSQL won’t, recommends the change for your target (community or EPAS), and keeps you and your copilot in control of the parts that actually require judgment.
Reproduce this walkthrough against the bundled sample apps: github.com/EnterpriseDB/swordfish-sample-apps. Swordfish itself (Apache-2.0): github.com/EnterpriseDB/swordfish-migrations