Want to deploy your JVM, Node.js and Go apps effortlessly to AWS? Try our service Boxfuse

SQL Server

Supported Versions

Drivers

Microsoft (recommended) jTDS
Supported versions 4.0 and later 1.3.1 and later
URL format jdbc:sqlserver://host:port;databaseName=database jdbc:jtds:sqlserver://host:port/database
Ships with Flyway Command-line Yes Yes
Maven Central coordinates com.microsoft.sqlserver:mssql-jdbc:6.2.2.jre8 net.sourceforge.jtds:jtds:1.3.1
Default Java class com.microsoft.sqlserver.jdbc.SQLServerDriver net.sourceforge.jtds.jdbc.Driver

SQL Script Syntax

Compatibility

  • DDL exported by SQL Server can be used unchanged in a Flyway migration.
  • Any SQL Server sql script executed by Flyway, can be executed by Sqlcmd, SQL Server Management Studio and other SQL Server-compatible tools (after the placeholders have been replaced).

Example

/* Single line comment */
CREATE TABLE Customers (
CustomerId smallint identity(1,1),
Name nvarchar(255),
Priority tinyint
)
CREATE TABLE Sales (
TransactionId smallint identity(1,1),
CustomerId smallint,
[Net Amount] int,
Completed bit
)
GO

/*
Multi-line
comment
*/
-- TSQL
CREATE TRIGGER dbo.Update_Customer_Priority
 ON dbo.Sales
AFTER INSERT, UPDATE, DELETE
AS
WITH CTE AS (
 select CustomerId from inserted
 union
 select CustomerId from deleted
)
UPDATE Customers
SET
 Priority =
   case
     when t.Total < 10000 then 3
     when t.Total between 10000 and 50000 then 2
     when t.Total > 50000 then 1
     when t.Total IS NULL then NULL
   end
FROM Customers c
INNER JOIN CTE ON CTE.CustomerId = c.CustomerId
LEFT JOIN (
 select
   Sales.CustomerId,
   SUM([Net Amount]) Total
 from Sales
 inner join CTE on CTE.CustomerId = Sales.CustomerId
 where
   Completed = 1
 group by Sales.CustomerId
) t ON t.CustomerId = c.CustomerId
GO

-- Placeholder
INSERT INTO ${tableName} (name) VALUES ('Mr. T');

Limitations

DB2