IF NOT EXISTS(
  SELECT name
  FROM sys.databases
  WHERE name = '{{ __mssql_test_db_name }}'
)
BEGIN
  PRINT 'Creating the {{ __mssql_test_db_name }} database';
  CREATE DATABASE {{ __mssql_test_db_name }};
  PRINT 'The {{ __mssql_test_db_name }} database created successfully';
END
ELSE
BEGIN
  PRINT 'The {{ __mssql_test_db_name }} database already exists, skipping';
END
GO

USE {{ __mssql_test_db_name }};
GO

IF NOT EXISTS (
  SELECT name, xtype
  FROM sysobjects
  WHERE name='Inventory' and xtype='U'
)
BEGIN
  PRINT 'Adding the Inventory table to the {{ __mssql_test_db_name }} database';
  CREATE TABLE Inventory (id INT, name NVARCHAR(50), quantity INT);
  INSERT INTO Inventory VALUES (1, 'apple', 100);
  INSERT INTO Inventory VALUES (2, 'orange', 150);
  INSERT INTO Inventory VALUES (3, 'banana', 154);
  INSERT INTO Inventory VALUES (4, N'バナナ', 170);
  PRINT 'The Inventory table created successfully';
END
ELSE
BEGIN
  PRINT 'The Inventory table already exists, skipping';
END
GO