Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
91 views

SQL Server To PostgreSQL Migration Reference

This document provides a reference for migrating from Microsoft SQL Server to PostgreSQL. It lists the data type conversions between the two databases in 34 rows, such as converting SQL Server's BIGINT to PostgreSQL's BIGINT. It also shows how to convert 2 common SQL functions, such as replacing SQL Server's DATEADD with PostgreSQL's INTERVAL expression and SQL Server's ISNULL with PostgreSQL's COALESCE.

Uploaded by

tom
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views

SQL Server To PostgreSQL Migration Reference

This document provides a reference for migrating from Microsoft SQL Server to PostgreSQL. It lists the data type conversions between the two databases in 34 rows, such as converting SQL Server's BIGINT to PostgreSQL's BIGINT. It also shows how to convert 2 common SQL functions, such as replacing SQL Server's DATEADD with PostgreSQL's INTERVAL expression and SQL Server's ISNULL with PostgreSQL's COALESCE.

Uploaded by

tom
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

sqlines.com http://www.sqlines.

com/sql-server-to-postgresql

Microsoft SQL Server to PostgreSQL Migration Reference


Technical information on migration from Microsoft SQL Server to PostgreSQL.

Data Types
Converting data types:

SQL Server PostgreSQL

1 BIGINT 64-bit integer BIGINT

2 BINARY(n) Fixed-length byte string BYTEA

3 BIT 1, 0 or NULL BOOLEAN

4 CHAR(n), Fixed-length character string, 1 ⇐ n ⇐ 8000 CHAR(n), CHARACTER(n)


CHARACTER(n)

5 DATE Date (year, month and day) DATE

6 DATETIME Date and time with fraction TIMESTAMP(3)

7 DATETIME2(p) Date and time with fraction TIMESTAMP(p)

8 DATETIMEOFFSET(p) Date and time with fraction and time zone TIMESTAMP(p) WITH TIME
ZONE

9 DECIMAL(p,s), DEC(p,s) Fixed-point number DECIMAL(p,s), DEC(p,s)

10 DOUBLE PRECISION Double-precision floating-point number DOUBLE PRECISION

11 FLOAT(p) Floating-point number DOUBLE PRECISION

12 IMAGE Variable-length binary data, ⇐ 2G BYTEA

13 INT, INTEGER 32-bit integer INT, INTEGER

14 MONEY 64-bit currency amount MONEY

15 NCHAR(n) Fixed-length Unicode UCS-2 string CHAR(n)

16 NTEXT Variable-length Unicode UCS-2 data, ⇐ 2G TEXT

17 NUMERIC(p,s) Fixed-point number NUMERIC(p,s)

18 NVARCHAR(n) Variable-length Unicode UCS-2 string VARCHAR(n)

19 NVARCHAR(max) Variable-length Unicode UCS-2 data, ⇐ 2G TEXT

20 REAL Single-precision floating-point number REAL


21 ROWVERSION Automatically updated binary data BYTEA

22 SMALLDATETIME Date and time TIMESTAMP(0)

23 SMALLINT 16-bit integer SMALLINT

24 SMALLMONEY 32-bit currency amount MONEY

25 TEXT Variable-length character data, ⇐ 2G TEXT

26 TIME(p) Time (hour, minute, second and fraction) TIME(p)

27 TIMESTAMP Automatically updated binary data BYTEA

28 TINYINT 8-bit unsigned integer, 0 to 255 SMALLINT

29 UNIQUEIDENTIFIER CHAR(16)
16-byte GUID (UUID) data

30 VARBINARY(n) Variable-length byte string, 1 ⇐ n ⇐ 8000 BYTEA

31 VARBINARY(max) Variable-length binary data, ⇐ 2G BYTEA

32 VARCHAR(n) Variable-length character string, 1 ⇐ n ⇐ VARCHAR(n)


8000

33 VARCHAR(max) TEXT
Variable-length character data, ⇐ 2G

34 XML XML data XML

Built-in SQL Functions


Converting SQL functions:

SQL Server PostgreSQL

1 DATEADD Add an interval to datetime INTERVAL expression

2 ISNULL(exp, replacement) Replace NULL with the specified value COALESCE(exp, replacement)

You might also like