babelfishpg_tsql
babelfishpg_tsql
babelfish : SQL Server Transact SQL compatibility
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9310 | babelfishpg_tsql | babelfish | 5.5.0 | SIM | Apache-2.0 | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r | No | Yes | No | Yes | yes | no |
| Relationships | |
|---|---|
| Requires | babelfishpg_common uuid-ossp |
| Need By | babelfishpg_tds |
| See Also | babelfishpg_money pg_hint_plan tds_fdw session_variable orafce pgtt db_migrator |
| Siblings | babelfishpg_common babelfishpg_tds babelfishpg_money |
special case: this extension only works on wiltondb kernel fork
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 5.5.0 | 18 17 16 15 14 | babelfish | babelfishpg_common, uuid-ossp |
| RPM | PIGSTY | 5.5.0 | 18 17 16 15 14 | babelfish_$v | babelfishpg_$v, antlr4-runtime413 |
| DEB | PIGSTY | 5.5.0 | 18 17 16 15 14 | babelfishpg-$v-babelfish | babelfishpg-$v, libantlr4-runtime413 |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
el8.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
el9.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
el9.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
el10.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
el10.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
d12.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
d12.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
d13.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
d13.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
u22.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
u22.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
u24.x86_64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
u24.aarch64 | MISS | PIGSTY 5.5.0 | MISS | MISS | MISS |
Source
pig build pkg babelfish; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install babelfish; # install via package name, for the active PG version
pig install babelfishpg_tsql; # install by extension name, for the current active PG version
pig install babelfishpg_tsql -v 17; # install for PG 17Create this extension with:
CREATE EXTENSION babelfishpg_tsql CASCADE; -- requires babelfishpg_common, uuid-osspUsage
The babelfishpg_tsql extension provides Microsoft SQL Server Transact-SQL (T-SQL) compatibility for PostgreSQL as part of the Babelfish project. Applications written for SQL Server can connect and run queries against PostgreSQL with minimal changes.
Enabling
CREATE EXTENSION babelfishpg_tsql;Key Features
- T-SQL Language Support: Understands T-SQL syntax including stored procedures, functions, triggers, and batches
- SQL Server Wire Protocol: Applications can connect using the TDS (Tabular Data Stream) protocol on port 1433
- System Procedures: Common
sp_system stored procedures are available - System Views: SQL Server catalog views (e.g.,
sys.tables,sys.columns,sys.objects) - Multi-Database Semantics: Supports SQL Server-style database/schema separation
Supported T-SQL Features
BEGIN...ENDblocks,IF...ELSE,WHILEloopsTRY...CATCHerror handling- Temporary tables (
#temp,##global_temp) - Table variables (
DECLARE @t TABLE (...)) IDENTITYcolumns and@@IDENTITY/SCOPE_IDENTITY()TOPclause,OUTPUTclauseMERGEstatements- Common Table Expressions (CTEs)
- Cross-database queries within the same instance
EXEC/EXECUTEfor dynamic SQL- SQL Server-style string concatenation and NULL handling
PRINTandRAISERRORstatements
Connecting via TDS Protocol
Applications can connect using SQL Server drivers (JDBC, ODBC, ADO.NET) to the TDS listener port (default 1433):
Server: hostname
Port: 1433
Database: mydbNotes
- Requires
babelfishpg_commonextension - Part of the Babelfish for PostgreSQL project (Apache 2.0 / PostgreSQL license)
- Not all T-SQL features are supported; check the Babelfish compatibility reference
Last updated on