我正在尝试使用 Invoke-SQLCmd powershell 命令自动执行 SQL 脚本。作为来源,我有一个由 SSDT Schema Compare 生成的脚本(4000 行,全部在事务内部)。我通过以下方式触发此脚本:
Invoke-SQLCmd -InputFile "$Path" -ServerInstance "$Server" -Database "$DbName" -ErrorAction "Stop"
作为输出,我收到以下错误:
Invoke-SQLCmd : Could not allocate a new page for database 'TEMPDB' because of insufficient disk space in filegroup 'DEFAULT'. [...]
我知道这个问题可能与 testdb 磁盘上的可用空间不足有关,但是有趣的是,当从同一数据库上的 SQL Server Management Studio 执行该脚本时,它已成功完成。
问题是这怎么可能以及如何使这个脚本在 PowerShell 中正常工作。