SQLines tools can help you transfer data, convert database schema (DDL), views, stored procedures, functions, triggers, queries and SQL scripts from Microsoft SQL Server (MSSQL, MS SQL), Azure SQL Database, Azure Synapse to IBM DB2:
Databases:
Converting data types:
SQL Server | DB2 | |
CHAR | Fixed-length character string | CHAR |
INT, INTEGER | 32-bit integer | INT, INTEGER |
SMALLINT | 16-bit integer | SMALLINT |
VARCHAR | Variable-length character string | VARCHAR |
Converting table definitions:
SQL Server | DB2 | |||
1 | IDENTITY(start, increment) | Identity column | GENERATED ALWAYS AS IDENTITY (START WITH start INCREMENT BY increment) |
|
2 | PRIMARY KEY (col ASC, … ) | Primary key | PRIMARY KEY (col, … ) | ASC, DESC cannot be specified |
Converting SQL queries:
SQL Server | DB2 | ||
1 | SELECT … FROM | Result set from a procedure | DECLARE CURSOR WITH RETURN and OPEN |
Converting SQL INSERT statement:
SQL Server | DB2 | |||
1 | INSERT [INTO] table … | INSERT INTO table … | INTO keyword is required |
Converting Transact-SQL user-defined functions:
SQL Server | DB2 | |
1 | CREATE FUNCTION | ALTER FUNCTION name | CREATE OR REPLACE FUNCTION name |
2 | @param [AS] datatype = default | p_param datatype DEFAULT default |
3 | RETURNS datatype(len) | RETURNS datatype(len) |
4 | Optional AS before the function body | Removed |
5 | Optional statement delimiter | ; is added after each statement |
For more information, see Conversion of Transact-SQL Statements.
Converting Transact-SQL stored procedures:
SQL Server | DB2 | |
1 | CREATE PROCEDURE name | CREATE OR REPLACE PROCEDURE name |
2 | @param [AS] datatype = default | p_param datatype DEFAULT default |
3 | Optional AS before the procedure body | Removed |
4 | Optional statement delimiter | ; is added after each statement |
5 | GO command at the end of procedure | Removed |
For more information, see Conversion of Transact-SQL Statements.
Variable declaration and assignment:
SQL Server | DB2 | |
1 | DECLARE @v1 type1, @v2 type2, … | DECLARE v1 type1; DECLARE v2 type2, DECLARE … |
Converting SQL statements:
SQL Server | DB2 | |||
1 | USE name | Change the database | SET SCHEMA 'name' | If databases are mapped to schemas |