如何使用azure devops管道执行sql脚本 [英] how to execute sql script using azure devops pipeline
问题描述
我有要使用Azure DevOps管道执行的SQL脚本
I have SQL script which I want to execute using azure DevOps pipeline
我找到了多个SQL任务,但是找不到可以传递sql server,数据库名称和登录详细信息的任何必需任务.有任何可用的任务吗?
I found multiple tasks for SQL but can not find any required task where I can pass sql server , database name and login details. Is there any task available for this ?
如果没有可用的任务,并且执行的唯一方法是powershell脚本为此提供任何示例可用的脚本?
If there is not any task available and only way to execute is powershell script any sample available script for this ?
推荐答案
您可以使用PowerShell执行sql脚本.示例:
You can use PowerShell to execute sql scripts. Example:
Invoke-Sqlcmd -InputFile "$(scriptfilepath)" -ServerInstance $(sqlserver) -Database $(dbname) -Username "$(username)" -Password "$(pwd)" -QueryTimeout 36000 -Verbose
添加自定义变量(scriptfilepath,sqlserver等)并为其设置值.
Add custom variables (scriptfilepath, sqlserver, ...) and set values to them.
这篇关于如何使用azure devops管道执行sql脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!