0

I created a cmd file that basically executes all sql scripts sequentially. I am using a windows private build agent in VSTS. How do I execute this .cmd file? Is there any other task that executes multiple sql scripts against an Azure SQL database? Any suggestions will help. Below is the contents of cmd file:

@Echo Off FOR /f %%i IN ('DIR *.Sql /B') do call :RunScript %%i GOTO :END

:RunScript Echo Executing Script: %1 sqlcmd -S <> -U <> -P <> -d PFUTest -i %1 -o log.txt Echo Completed Script: %1

:END

2 Answers2

1

Regarding execute sql scripts against an Azure SQL database, you can use Azure SQL Database Deployment task (Select SQL Script file or Inline SQL Script in Type input box of Deployment Package section.

With batch script, you can call Invoke-Sqlcmd command to run SQL scripts.

You may need to add Firewall rule during build/release, refer to this thread: Allow VSTS to update test database

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
0

Use the Batch Script task.

However, in general you should use SQL Server Data Tools to manage your database deployments.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120