You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10下sqlcmd连接Azure Synapse报错及替代工具咨询

解决Windows 10终端连接Azure Synapse专用SQL池的工具推荐及问题修复

先修复Windows版sqlcmd的报错

你遇到的QUOTED_IDENTIFIER错误,是因为Azure Synapse专用SQL池要求该参数必须设为ON,而Windows版sqlcmd默认是OFF。可以通过添加-I参数强制开启来解决,同时用-E指定Windows身份验证:

sqlcmd -S foo -d bar -E -I

如果要执行脚本文件,加上-i参数:

sqlcmd -S foo -d bar -E -I -i your_script.sql

替代工具推荐(支持Windows身份验证)

如果上述修复仍有问题,推荐以下更适配Azure Synapse的终端工具:

1. Azure Data Studio 命令行

Azure Data Studio是微软官方数据库工具,其命令行工具azdata完美支持Synapse,原生支持Windows身份验证:

  • 安装Azure Data Studio后,执行脚本的命令:
azdata sql query --server foo --database bar --authentication Integrated --input-file your_script.sql
  • 也可以直接打开Azure Data Studio的GUI界面,导入脚本执行,还能查看Synapse专用池的元数据和执行计划。

2. PowerShell SqlServer模块

适合用PowerShell做自动化脚本的场景,支持Windows身份验证:

  • 先安装模块(需管理员权限):
Install-Module -Name SqlServer
  • 执行SQL脚本:
Invoke-SqlCmd -ServerInstance foo -Database bar -IntegratedSecurity -InputFile your_script.sql

3. ODBC命令行工具(isql)

通过ODBC数据源连接,支持Windows身份验证:

  • 确保已安装ODBC Driver 17 for SQL Server,然后在Windows ODBC数据源管理器中创建指向Synapse专用池的系统DSN,选择Windows身份验证。
  • 执行脚本的命令:
isql -d "你的Synapse DSN名称" -i your_script.sql

内容的提问来源于stack exchange,提问作者John Scott Stensland

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 07:14:56