Convert Microsoft SQL Server T-SQL to Java

Migrate Microsoft SQL Server T-SQL to Java

Make the most of automated migration to focus on your business core

Get started. Check migration plans

Many companies have used our tools and provided excellent feedback on their performance

  • Capterra logo

    4.8

  • Clutch logo

    4.9


Migration opportunities with Ispirer

Ispirer Ecosystem automates your migration routine to enable quick and smart transformation of any database. Double the migration speed with our comprehensive solutions.

  • With Ispirer Toolkit only

    • Free InsightWays tool to analyze your SQL Server database and estimate migration complexity
    • Assistance in Ispirer Toolkit configuration
    • Automated migration of the entire database schema, tables, SQL objects, business logic, and data
    • Timely customization of the Ispirer Toolkit to maximize automation rate
    • Expert support
    Get started — it’s free

    Trial is free. No payment

    With Ispirer Toolkit -- card image
  • With Ispirer Toolkit as a part of migration service

    • Detailed analysis of your SQL Server database and tailored migration roadmap
    • Migration of data and database schema, including SQL objects, business logic, and tables
    • Team of database conversion experts and a dedicated Project Manager
    • Regular updates on the project status
    • Post-migration refinement and testing
    Get started — it’s free

    Trial is free. No payment

    With Ispirer Toolkit -- card image

Ispirer Ecosystem for automated migration

Ispirer has a solution to unlock the full potential of your database. Our team helps you to move business logic to an application layer seamlessly to advance the database performance.

Source database

  • SQL Server
Read-only access

ODBC

Files with business logic SQL code

  • SQL Server
How Migration work

Seamless integration, limitless possibilities!

Application target Code

  • Java
  • JDBC
  • Spring
  • Hibernate
  • Automated conversion of SQL objects to application code. Ispirer Ecosystem supports Oracle, SQL Server, Sybase, PostgreSQL, Java, C#, Python, etc.
  • In case of changing the RDBMS, embedded SQL will be automatically rewritten to adhere to the syntax of the new database.
  • Migration with or without connection to databases. Both options allow you to successfully migrate business logic from the database to the application layer. However, connecting to the database allows the migration tool to take into account additional data from the database and helps improve the conversion.

Capabilities SQL Server to Java conversion

Our automated migration engine analyzes the original Microsoft T-SQL code at the Abstract Syntax Tree (AST) level and accurately transforms:

  • Scalar-valued, inline and multi-statement table-valued function
  • Control flow statements (IF…ELSE, WHILE, TRY…CATCH)
  • Stored procedures
  • Table-valued parameters (TVPs)
  • Transactions with BEGIN TRAN, COMMIT, ROLLBACK
  • Built-in functions (ISNULL, IIF, DATEADD, PATINDEX,FORMAT, etc.)
  • Common Table Expressions (CTEs) and recursive queries
  • Temporary tables and table variables (#temp, @tableVar)
  • User-defined types (scalar & table types)
  • Dynamic SQL (EXEC, sp_executesql)
  • Error handling via ERROR_MESSAGE(), ERROR_NUMBER() mapped to Java exceptions
  • Output parameters and return values from stored procedures

Migration details overview

  • Ispirer Toolkit automates

    Ispirer Toolkit automates icon

    Ispirer Toolkit automatically converts SQL Server to Java, considering its specifics

    Both conversion with connection to the source database, as well as conversion of files containing SQL scripts are possible.

    Converted to a Java class icon

    SQL objects conversion

    Every database object (stored procedures, functions, etc.) is automatically transformed into a Java class. Names of the classes are formed based on object names, taking into account the Java Naming Convention.

    At the same time, tables, views, triggers remain on the database side.

    Different database icon

    Moreover, you can migrate SQL Server to another database

    In this case, you need a Java application to work with a different database, Ispirer Toolkit can convert Embedded SQL and the database itself.

  • Variable Conversion

    Variable Conversion icon

    Ispirer Toolkit supports conversion of all SQL Server data types

    The tool automatically converts function and procedure variables to method variables.

  • Code Conversion

    Code Conversion icon

    Procedures and functions are converted to classes with one method

    SQL Server system functions and procedures are converted either to the same Java methods, if any, or to the methods of helper class.

  • Working with Database

    Working with Database icon

    The automated conversion supports multiple data access options: from classic JDBC to Spring JDBC Template and Hibernate (using native queries)

    This flexibility ensures that the generated code can be seamlessly integrated into different technology stacks while preserving familiar tools for working with the database.

Migration demo

Check out how Ispirer Toolkit migrates databases efficiently, minimizing the need for manual corrections

Migrate Smarter. Evolve Faster

Over 400+ ways to migrate

Give it a try now. Book a demo

Dive into tool’s features

  • PostgreSQL
  • Oracle
  • AlloyDB
  • SQL Server
  • Informix
  • MySQL
  • DB2
  • MariaDB
  • Sybase ASE
  • PostgreSQL
  • Oracle
  • AlloyDB
  • SQL Server
  • Informix
  • MySQL
  • DB2
  • MariaDB
  • Sybase ASE
  • MSSQL
  • COBOL
  • Azure
  • Progress 4GL
  • SAP
  • PowerBulder
  • .NET
  • Delphi
  • MSSQL
  • COBOL
  • Azure
  • Progress 4GL
  • SAP
  • PowerBulder
  • .NET
  • Delphi

SQL Server to Java migration service overview

Migration

  • DB schema conversion
  • Data migration testing
  • Data integrity testing
  • APP changes: API, ESQL, logic shift to APP layer

Assessment

  • Obtaining access
  • Project discussion
  • Making migration plan
  • Creating SOW
Start

More than 2K users use this way to
successfully convert their database

Manual review & corrections

  • Manual corrections
  • Internal testing

Functional testing

  • Creating snapshots with data
  • Testing APP and DB on snapshots
  • Fixing all logical issues

Performance testing

  • Performance testing
  • Converted code review
  • Code refactoring
  • Extra code optimization

Data migration

  • Prod data migration

Cutover

  • Switching DB and APP
  • Providing user access
  • System startup
  • Obtaining access
  • Project discussion
  • Making migration plan
  • Creating SOW
  • DB schema conversion
  • Data migration testing
  • Data integrity testing
  • APP changes: API, ESQL, logic shift to APP layer
  • Manual corrections
  • Internal testing
  • Creating snapshots with data
  • Testing APP and DB on snapshots
  • Fixing all logical issues
  • Performance testing
  • Converted code review
  • Code refactoring
  • Extra code optimization
  • Prod data migration
  • Switching DB and APP
  • Providing user access
  • System startup

Conversion Samples of Microsoft SQL Server T‑SQL to Java

Ispirer Toolkit analyzes all object dependencies during the conversion process and provides not only line-by-line conversion, but resolves type conversions as well. The software understands and transforms the necessary inheritance dependencies. It parses the entire source code, builds an internal tree with all the information about the objects, and uses it in the migration process.

We convert SQL Server stored procedures to Java with attention to all the specifics

  • System functions (GETDATE(), CONVERT, LEN). During migration, they are typically mapped to equivalent utility methods in our Java framework or standard libraries.
  • Control flow (IF, WHILE, RETURN). In Java, these statements are directly translated to corresponding control structures (if, while, return), preserving the original logic flow.
  • Error handling (TRY...CATCH, THROW, ERROR_MESSAGE(), ERROR_NUMBER() etc.). T-SQL error-handling mechanisms are represented by exception handling in Java. Errors are captured via try-catch blocks and delegated to utility classes (e.g., ErrorUtil) for unified exception processing and logging.
  • Error logging into a dedicated table.
  • Cursors for row-by-row processing.
  • Output parameters to return additional values back to the caller. In Java, output parameters are typically represented as Map structures ensuring clarity in the returned results.

The code samples below provide you with more details.

  • Microsoft SQL Server T-SQL

    1.  
    2. CREATE PROCEDURE sp_demo_conversion
    3. @DeptId INT,
    4. @EmployeeCount INT OUTPUT -- Output parameter
    5. AS
    6. BEGIN
    7.  
    8. DECLARE @EmpId INT;
    9. DECLARE @EmpName NVARCHAR(100);
    10. DECLARE @CurrentDate DATETIME = GETDATE();
    11.  
    12. PRINT 'Procedure started at ' + CONVERT(VARCHAR, @CurrentDate, 120);
    13.  
    14. BEGIN TRY
    15. -- Validate input parameter
    16. IF @DeptId IS NULL OR @DeptId <= 0
    17. THROW 50001, 'Invalid Department Id', 1;
    18.  
    19. -- Count employees in department and return via output parameter
    20. SELECT @EmployeeCount = COUNT(*)
    21. FROM Employees
    22. WHERE DeptId = @DeptId;
    23.  
    24. PRINT 'Total employees in department: ' + CAST(@EmployeeCount AS VARCHAR);
    25.  
    26. -- Exit early if no employees found
    27. IF @EmployeeCount = 0
    28. BEGIN
    29. PRINT 'No employees found';
    30. RETURN;
    31. END
    32.  
    33. -- Cursor to iterate employees
    34. DECLARE emp_cursor CURSOR FOR
    35. SELECT EmpId, EmpName
    36. FROM Employees
    37. WHERE DeptId = @DeptId;
    38.  
    39. OPEN emp_cursor;
    40.  
    41. FETCH NEXT FROM emp_cursor INTO @EmpId, @EmpName;
    42.  
    43. WHILE @@FETCH_STATUS = 0
    44. BEGIN
    45. -- Conditional branch
    46. IF LEN(@EmpName) > 10
    47. PRINT 'Long name: ' + @EmpName;
    48. ELSE
    49. PRINT 'Short name: ' + @EmpName;
    50.  
    51. -- Try to update employee
    52. UPDATE Employees
    53. SET LastUpdated = @CurrentDate
    54. WHERE EmpId = @EmpId;
    55.  
    56. FETCH NEXT FROM emp_cursor INTO @EmpId, @EmpName;
    57. END
    58.  
    59. CLOSE emp_cursor;
    60. DEALLOCATE emp_cursor;
    61. END TRY
    62.  
    63. BEGIN CATCH
    64. -- Collect error details
    65. DECLARE @ErrMsg NVARCHAR(4000) = ERROR_MESSAGE();
    66. DECLARE @ErrNum INT = ERROR_NUMBER();
    67. DECLARE @ErrSeverity INT = ERROR_SEVERITY();
    68. DECLARE @ErrState INT = ERROR_STATE();
    69.  
    70. PRINT 'Error occurred: ' + @ErrMsg;
    71.  
    72. -- Log error into a dedicated table
    73. INSERT INTO ErrorLog (ErrorDate, ErrorNumber, Severity, State, Message)
    74. VALUES (GETDATE(), @ErrNum, @ErrSeverity, @ErrState, @ErrMsg);
    75.  
    76. -- Re-throw the error for higher-level handling
    77. THROW;
    78. END CATCH;
    79.  
    80. PRINT 'Procedure finished at ' + CONVERT(VARCHAR, GETDATE(), 120);
    81. END
    82.  

    → Java

    1.  
    2. import com.sql4j.db.cursor.*;
    3. import com.sql4j.db.implementation.Dao;
    4. import com.sql4j.db.util.ResultSetService;
    5. import com.sql4j.exception.*;
    6. import com.sql4j.transaction.aop.TransactionStatus;
    7. import com.sql4j.util.*;
    8. import java.time.LocalDateTime;
    9. import java.util.*;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Service;
    12. import org.springframework.web.context.annotation.RequestScope;
    13. @Service
    14. @RequestScope
    15. public class SpDemoConversion implements ISpDemoConversion {
    16. @Autowired
    17. private ErrorUtil errorUtil;
    18. @Autowired
    19. private ResultSetService resultSetService;
    20. @Autowired
    21. private Dao dao;
    22. @Autowired
    23. private CursorStatusService cursorStatusService;
    24. @TransactionStatus
    25. @Override
    26. public Map< String, Object > spSpDemoConversion(Integer deptid, Integer employeecount) {
    27. Map<String, Object> outData = new HashMap<>();
    28. outData.put("retStatus", 0);
    29.  
    30. try {
    31. Integer empid = null;
    32. String empname = null;
    33. LocalDateTime currentdate = TimeUtil.getDate();
    34. System.out.println(StringUtil.concatNullable("Procedure started at ", Converter.toString(currentdate, 120)));
    35.  
    36. try {
    37. errorUtil.beginProtectedBlock();
    38.  
    39. if (deptid == null || ComparisonUtil.isLessOrEqual(deptid, 0)) {
    40. errorUtil.throwError(50001, "Invalid Department Id", 1);
    41. }
    42.  
    43. dao.selectRes("SELECT COUNT(*) " +
    44. "FROM Employees " +
    45. "WHERE DeptId = :DEPTID ", "DEPTID", deptid);
    46. System.out.println(StringUtil.concatNullable("Total employees in department: ", Converter.toString(employeecount)));
    47.  
    48. if (ComparisonUtil.areEqual(employeecount, 0)) {
    49. System.out.println("No employees found");
    50. return outData;
    51. }
    52.  
    53. CursorReader empCursor = new CursorReader(cursorStatusService, true, "SELECT EmpId, EmpName " +
    54. "FROM Employees " +
    55. "WHERE DeptId = :DEPTID ", "DEPTID", deptid);
    56. empCursor.open();
    57.  
    58. if (empCursor.fetchNext()) {
    59. empid = empCursor.getColumnValue(Integer.class);
    60. empname = empCursor.getColumnValue(String.class);
    61. }
    62.  
    63. while (ComparisonUtil.areEqual(cursorStatusService.getFetchStatus(), 0)) { // Conditional branch
    64. if (ComparisonUtil.isGreaterThan(StringUtil.length(empname), 10)) {
    65. System.out.println(StringUtil.concatNullable("Long name: ", empname));
    66. }
    67. else {
    68. System.out.println(StringUtil.concatNullable("Short name: ", empname));
    69. }
    70.  
    71. // Try to update employee
    72. dao.update("UPDATE Employees " +
    73. "SET LastUpdated = :CURRENTDATE " +
    74. "WHERE EmpId = :EMPID ", "CURRENTDATE", currentdate, "EMPID", empid);
    75.  
    76. if (empCursor.fetchNext()) {
    77. empid = empCursor.getColumnValue(Integer.class);
    78. empname = empCursor.getColumnValue(String.class);
    79. }
    80. }
    81.  
    82. empCursor.close();
    83. empCursor.deallocate();
    84. }
    85. catch (GeneralException e) {
    86. errorUtil.failProtectedBlock();
    87. String errmsg = e.getMessage();
    88. Integer errnum = e.getErrorNumber();
    89. Integer errseverity = e.getSeverity();
    90. Integer errstate = e.getState();
    91. System.out.println(StringUtil.concatNullable("Error occurred: ", errmsg));
    92. dao.update("INSERT INTO ErrorLog (ErrorDate, ErrorNumber, Severity, State, Message) " +
    93. "VALUES (GETDATE(), :ERRNUM, :ERRSEVERITY, :ERRSTATE, :ERRMSG) ", "ERRNUM", errnum, "ERRSEVERITY", errseverity, "ERRSTATE", errstate, "ERRMSG", errmsg);
    94. throw e;
    95. }
    96. finally {
    97. errorUtil.finalizeProtectedBlock();
    98. }
    99.  
    100. System.out.println(StringUtil.concatNullable("Procedure finished at ", Converter.toString(TimeUtil.getDate(), 120)));
    101. return outData;
    102. }
    103. finally {
    104. outData.put("dataSet", resultSetService.getResultSet());
    105. outData.put("employeecount", employeecount);
    106. }
    107. }
    108. }
    109.  

They succeeded using Ispirer Toolkit

Enhancing Performance: Oracle to Java Migration Automation

Oracle → Java, PostgreSQL

Target: Java, PostgreSQL

Enhancing Performance case card

Project Scope

1 250 000 LoC

Project Duration

14 months

Industry

Software Developer and Provider

Consulting Firm Cuts Migration Costs by 65% with Ispirer

SQL Server → Java, PostgreSQL

Target: Java, PostgreSQL

Consulting Firm Cuts Migration case card

Project Scope

35 000 LoC

Project Duration

3 Months

Industry

Financial Consulting Firm

Achieving 95% automation in PostgreSQL database migration

Oracle, SQL Server → PostgreSQL

Target: PostgreSQL

Achieving 95% automation in PostgreSQL database migration case card

Project Scope

1 700 000 LoC

Project Duration

12 Months

Industry

Contingent Workforce Management

Sybase ASE to MySQL: 100% automated migration

Sybase ASE → MySQL

Target: MySQL

Sybase ASE to MySQL: 100% automated migration case card

Project Scope

300 000 LoC

Project Duration

12 Months

Industry

Financial Data Utility Provider

Helping HR Software Leader: DB2 OS/390 to SQL Server

DB2 OS/390 → SQL Server

Target: SQL Server

Helping HR Software Leader case card

Project Scope

400 000 LoC

Project Duration

3 Months

Industry

Software Developer and Provider


Trust us with your migration project

  • High quality SQL code conversion

    Expert system with 20.000+ conversion rules and 100.000+ automated tests

  • Flexibility

    Nimble configuration with 300+ parameters and options for SQL objects and data multithread migration

  • Seasoned team

    Ensuring high security and performance standards is what we do best, thanks to our impressive expertise in building reliable and scalable solutions

  • Technology expertise

    With 25+ years of experience, our team has gained a wide pool of expertise in various programming languages, from the rarest to the most popular ones

  • We comply with ISO 27001

    security management requirements with comprehensive policies and processes, advanced security technology, and skilled professionals

  • Comprehensive migration analysis

    Intuitive and instructive reports for cost-effective post-migration polishing

  • Proprietary tools

    We employ Ispirer proprietary tools, underscoring our dedication to delivering the utmost reliability and performance solutions. The toolkit is compiled daily and continually integrates dozens of new conversion rules, enhancing the automation capabilities

  • Free smart assessment

    Ispirer's free InsightWays tool for migration scope and complexity evaluation

6 undeniable facts to choose conversion with Ispirer

  • Fact 1/6

    Enhanced agility

    Applications can offer more flexibility and agility in managing and modifying business logic than databases. It's easier and faster to update and iterate on application code rather than altering database architecture, structure, stored procedures and data.

    Enhanced agility -- card image
  • Fact 2/6

    Portability

    Business logic embedded within applications is more portable across different database systems or platforms. It can be beneficial if the business needs to switch database vendors or deploy the application in various environments.

    Portability -- card image
  • Fact 3/6

    Improved performance

    Application servers are much easier to scale than database servers. Depending on the load users create, an application can be placed in a container and used as needed. It will be much easier and cheaper to achieve the system's desired performance using Ispirer solutions.

    Improved performance -- card image
  • Fact 4/6

    RDBMS dependency eliminated

    Having business logic in the application layer unties your hands if you plan to change a database management system. This approach allows the simultaneous support of several databases.

    RDBMS dependency eliminated -- card image
  • Fact 5/6

    Modernization and innovation

    Migrating to Java can enable the adoption of new technologies and features, unlocking new business opportunities and driving innovation.

    Modernization and innovation -- card image
  • Fact 6/6

    No need for documentation

    We perform the migration using the source code. There is no need for detailed documentation to begin the migration as there is in development.

    No need for documentation -- card image

They chose Ispirer to revamp their database

Mixon, Magnit, CardinalHealth, and more have adopted SQLWays to boost their innovation life-cycle accelerate and manage their end-to-end innovation lifecycle

Magnit logo
CardinalHealth logo
University of Maryland logo
WorldLine logo
Poul Group logo
Utah state university logo

Oracle to PostgreSQL MS SQL Server to PostgreSQL

Migration project

50%

Migration time reduction

1.365K

Lines of SQL code

8 Tb

of data

Talent Management

"Ispirer Toolkit enabled a seamless migration of 8 TB of data and 1.36M lines of code from Oracle and SQL Server to PostgreSQL. The automation features reduced migration time by 50%, cutting costs and minimizing manual effort. The quality, precision, and support exceeded our expectations."

SQL Server to PostgreSQL

Migration project

70%

Migration time reduction

650K+

Lines of SQL code

700+ tables

of data

Healthcare Solutions

"Ispirer helped us migrate 700+ tables and 650+ stored procedures from SQL Server to PostgreSQL, reducing development time by 60%-70%. The tool efficiently handled case-sensitive issues and frequent data changes. The excellent support made the process easy, fast, and effective."

COBOL to Java

Migration project

6-month

Migration time reduction

100K+

Lines of code

200+

COBOL programs

Education

"Ispirer Toolkit enabled us to efficiently convert 200 COBOL programs with over 100,000 lines of code to Java. The tool produced high-quality, maintainable code, allowing our team to focus on infrastructure rather than conversion. Ispirer’s support was exceptional, often resolving issues within one business day."

Oracle 19c to PostgreSQL

Migration project

65%

Migration time reduction

1.500K

Lines of code

8 TB

of data

Payments & Financial Services

"Ispirer Toolkit helped us migrate 1.5 million lines of complex Oracle code to PostgreSQL, overcoming unique challenges with expert support. Their team provided customized solutions for a smooth transition. This migration is a key step in our cloud strategy, and we highly recommend Ispirer's services."

Firebird to PostgreSQL

Migration project

55%

Migration time reduction

25K+

Lines of SQL code

> 150 tables

per database

Manufacturing & Fleet Management

"Ispirer's Toolkit enabled the efficient migration of 150 tables and 25,000 lines of code from Firebird to PostgreSQL. The tool saved us time and reduced risks, while the Ispirer team provided excellent support throughout. Highly recommended for similar database migration projects."

Informix to Oracle

Migration project

78%

Migration time reduction

200K+

Lines of code

12 TB

of data

Governmental

"Ispirer MnMTK was crucial to our successful database migration, converting 12 TB of data and 200,000 lines of SQL code. The tool outperformed other solutions, saving us countless hours. The support team was responsive and effective—money well spent."

Are you still here? And wow, that's quite a lot you had to scroll through! 😄

Consult with our expert to better organize for you migration flow

Take control of your database
migration now

Book a demo

It only takes 5 minutes!

Cookie icon
THIS SITE USES COOKIES: By continuing to browse this site, you give your consent for cookies to be used. For more details, please read our Privacy Policy and Cookies Policy.
I Got it