I have a nice bash script that uses az cli to generate an Azure SQL Server (az sql server create) and SQL database (az sql db create).
I'd like to populate the database with tables and columns I have defined in a series of .sql files stored in Github.
Example file:
- Filename:
TST_HDR.sql - File contents:
-- Create a new table called 'TEST_HDR' in schema 'dbo'
-- Drop the table if it already exists
IF OBJECT_ID('dbo.TEST_HDR', 'U') IS NOT NULL
DROP TABLE dbo.TEST_HDR
GO
-- Create the table in the specified schema
CREATE TABLE dbo.TEST_HDR
(
tstID INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
tstGUID [NVARCHAR](50),
tstComments [NVARCHAR](2000),
tstHdrCreated DATETIME2,
tstHdrCreatedBy [NVARCHAR](255),
tstHdrLastUpdated DATETIME2,
tstHdrLastUpdatedBy [NVARCHAR](255),
tstHdrDeleted [NVARCHAR](3),
tstHdrDeletedBy [NVARCHAR](255),
tstHdrVersionNum INT
);
GO
Which bash (or other scripting) commands do I use to get these files from Github and execute them against the SQL database?