問題描述
我是 SQL 新手,嘗試使用 PowerShell 的 Invoke-SQLCmd
查詢 Azure SQL 數(shù)據(jù)庫(Adventureworks 示例).
I'm new to SQL, trying to query an Azure SQL Database (Adventureworks sample) using PowerShell's Invoke-SQLCmd
.
當(dāng)我在 Powershell 中嘗試以下命令時:
When I try the following command in Powershell:
我明白了:
我是否需要指定該表所在的數(shù)據(jù)庫?即,SQLDatabse"而不是master"?但是當(dāng)我將 Use SQLDatabase
添加到我的查詢時,它會引發(fā)另一個錯誤:
Do I need to specify what Database that table is under? Namely, "SQLDatabse" instead of "master"? But when I add Use SQLDatabase
to my query it throws another error:
注意:從 SQL Server Management Studio 執(zhí)行這些查詢會得到?jīng)]有錯誤的表.
Note: Executing these queries from SQL Server Management Studio gets me the table with no errors.
謝謝!
推薦答案
在命令參數(shù)中添加一個-Database [dbname]
:
Add a -Database [dbname]
to the command parameters:
https://msdn.microsoft.com/en-us/library/cc281720.aspx
這篇關(guān)于Azure SQL:使用 Powershell 的“Invoke-sqlcmd"的無效對象名稱在 Adventureworks 上的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!