I have all the SQL files checked into a repo on Azure devops. I have naming convention that allows me to know which .sql files are used by other .sql files (ex. file creates a view that is used by a stored procedure). I am wanting to force the use of the repo for tracking code changes, and would prefer not to use dacpac file. I want each function / view / stored procedure to have it's own file.
My question, how would I execute all .sql files matching '..\Functions\BASE_*.sql' against a database from an azure pipeline? I tried the below, but does not support multiple files being matched. Is there a better option that does? Do I need to script a loop and do it myself?
# pipeline
trigger:
- master
pool:
vmImage: 'windows-latest'
steps:
- task: SqlDacpacDeploymentOnMachineGroup@0
inputs:
TaskType: 'sqlQuery'
SqlFile: '$(System.DefaultWorkingDirectory)\Functions\BASE_*.sql'
ServerName: '$(SQL_ServerName).database.windows.net'
DatabaseName: '$(SQL_DatabaseName)'
AuthScheme: 'sqlServerAuthentication'
SqlUsername: '$(SQL_UserName)'
SqlPassword: '$(SQL_Password)'
The error I am getting is:
Starting: SqlDacpacDeploymentOnMachineGroup
==============================================================================
Task : SQL Server database deploy
Description : Deploy a SQL Server database using DACPAC or SQL scripts
Version : 0.3.23
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/sql-dacpac-deployment-on-machine-group
==============================================================================
##[error]Found more than one file to deploy with search pattern d:\a\1\s\Functions\BASE_*.sql. There can be only one.
Finishing: SqlDacpacDeploymentOnMachineGroup