So, i am tryingt to run a SQL-Query via Powershell with the Invoke-Sqlcmd-CMDLet. Pretty straight Forward:
Invoke-Sqlcmd -Query $Query -ServerInstance $DBServer -Database $DBName -Username $DBUser -Password $DBPass
($Query is "Select * FROM Inventar;
")
Now im getting an Error :
Invoke-Sqlcmd : Invalid object name 'Inventar'. At line:1 char:1 + Invoke-Sqlcmd -Query $Query -ServerInstance $DBServer -Database $DBName -Usernam ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Invoke-Sqlcmd], SqlPowerShellSqlExecutionException + FullyQualifiedErrorId : SqlError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand
ANYWAYS, i was able to run the Command with the following Query:
SELECT * FROM INFORMATION_SCHEMA.TABLES;
And it listed me all the Tables from the Database.
From there i've got the Table "Inventar", Kind of the error from This Question:
Azure SQL: Invalid Object Name using Powershell's "Invoke-sqlcmd" on Adventureworks
Except for that i already have the -Database attribute.
Maybe someone can help me out?
schema.Inventar
– HoneyBadger[****** \ ******].[Inventar]
? Mind you, its a weird schema name that may need to be fixed. – HoneyBadger