pgTSQL: Sybase & SQL Server CompatibilityPostgres is better than SQL Server, has great comparative benchmarks, and used used by Microsoft Skype to scale to 1 billion users.
"Developers are more likely to port SQL Server to Postgres because it is open source, supports more ANSI features, runs on more platforms, uses a different ACID model and has a great optimizer. " Joe Celko, Author of SQL For Smarties
"New Features" of SQL Server that have been in PostgreSQL for years
- Sequences (CREATE SEQUENCE s START WITH ..., SELECT NEXT VALUE FOR s)
- Ad-Hoc Query Paging (OFFSET, FETCH NEXT x ROWS ONLY)
- THROW keyword for re-throwing an exception in a T-SQL CATCH block
- Window order and frame clauses for window aggregate functions
- LAG, LEAD, FIRST_VALUE and LAST_VALUE window offset functions
- PERCENT_RANK and CUME_DIST window distribution functions
pgTSQL is Compatible with T-SQLT-SQL is the procedural programming language that is the next step in the History of Sybase & SQL Server.
The pgTSQL extension is available for installation through Postgres by BigSQL. First install the tds_fdw using BigSQL Manager or the PGC command line:
./pgc install pgtsql9-pg95
Then activate it, with the CREATE EXTENSION command, in the database you wish to use it in.
Now lets create a sample table in PostgreSQL and insert a few rows.
CREATE EXTENSION pgtsql;
Now we create a T-SQL compatible function in PostgreSQL and we are free from proprietary vendor lock-in!!
CREATE TABLE rdbms_supports_tsql ( organization varchar(10) primary key ); INSERT INTO rdbms_supports_tsql VALUES ('SYBASE'); INSERT INTO rdbms_supports_tsql VALUES ('SQL-SERVER'); INSERT INTO rdbms_supports_tsql VALUES ('POSTGRESQL BY BIGSQL');
CREATE OR REPLACE FUNCTION query_tsql_rdbms() RETURNS void AS $$ DECLARE @val int = 0 BEGIN SELECT count(*) INTO @val FROM rdbms_supports_tsql; IF @val = 2 PRINT 'Proprietary market featuring vendor lock-in' ELSE PRINT 'Open Source innovation means choices' END $$ LANGUAGE pltsql;
Development RoadmapJoin our open Development Community.
- Syntactical support for Stored Procedures (right now we are just Stored Functions).
- Full support for debugging T-SQL Stored Functions & Procedures in the server, CUI, and the pgAdmin3 GUI.
- Support for IDENTITY columns.
- Support for T-SQL style triggers.
- T-SQL compatible syntax support for out & inout parameters for functions and stored procs.
- Support for multiple result sets.
- Built-in T-SQL system (sp_) stored procedures & built-in functions.
- TSQL System Catalogs.
- Improving T-SQL error messages.
- Supporting the T-SQL BREAK statement.
- More complete support for the EXEC[UTE] statement for TSQL Stored Procedures.