The specified module 'SQLPS' was not loaded in azure VM - powershell

I create new Azure VM and i want to invoke some SQL Powershell commands like Import-Module SQLPS -DisableNameChecking. I have not install any sql server in VM, because i want to do operation on my azure database. so i need to install any sql server for it ?

No need to install SQL Server on the VM. But, you need to have Azure PowerShell and the SQLDB PowerShell cmdlets on the VM. I'd suggest to start by installing the Azure SDK. This link has more information on the steps: http://azure.microsoft.com/en-us/blog/windows-azure-sql-database-management-with-powershell/
Hope this helps.
Torsten

Related

How do you run many SQL commands against an Azure SQL database using an Azure Automation powershell runbook

I'm using Azure Automation to move an Azure SQL database from one resource to another(from Prod to Dev for example). After the database is copied, I would then like to run SQL script that adds some users and permissions. This would mean I need to run a handful of commands like "Create user..." and "alter role....". Most examples I've found use powershell to execute a single SQL command, but using that code to run many commands seems like it would result in an excessively long powershell script. In the on-prem world, I probably would have .sql file that gets executed. Any suggestions on how to achieve this easily using powershell in Azure Automation. Thanks!

Could not deploy package. Unable to connect to master or target server. You must have a user with the same password in master or target server

I am using self Hosted Agent (Windows 2019) with SQL Server 2019 in Azure DevOps. I am using "SQL Server database deploy" Task. And trying to deploy a dacpac with the database project created using VS2019. I am getting an error as
"Could not deploy package. Unable to connect to master or target server. You must have a user with the same password in master or target server."
When I check the task log, SQLPackage.exe was executed from the below path.
"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe"
But DAC folder is missing in the below path
"C:\Program Files (x86)\Microsoft SQL Server\150"
When I check the capabilities of agent pool, it showing the path of SQLPackage as
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\140\SQLPackage.exe".
But SQLPackage.exe is also available in the below path
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150"
Some links says it was known issue. And some links suggest to use Powershell task instead of "SQL Server database deploy" Task.
Please anyone let me know how to fix this issue.
What do you mean 'SQL Server database deploy Task' the WinRM SQL Server DB Deployment task or Azure SQL Database Deployment task?
Here, about your issue, we have some suggestions:
Make sure SQL Server is running
Use the correct SQL Server connection name
Double-check SQL Server username/password
SQL Server user needs correct server role
Try to upgrade the Microsoft.SqlServer.DacFx.x64 package from 140.3745.1 to latest stable.
Or you can try to Change the dacpac compatibility from 150 to 140.

PostgreSQL Job Scheduler on Azure DB for PostgreSQL

In Azure Database for PostgreSQL, how do I install a pgAgent?
As, its a PaaS only, I will not have access to the Server. In that case, if I need a pgAgent to install, how do I do it?
As per azure docs, it seems PgCron is available in flexible server type.

Running shp2pgsql in Azure cloud shell

I'm working with an Azure Postgresql database and am using the Cloud Shell to run psql scripts without problems. I'm now trying to load some shp files via the shp2pgsql command. The cloud shell responds by:
bash: shp2pgsql: command not found
Is it possible at all to use shp2pgsql with the Cloud Shell or I'm missing something? I've already successfully created the postgis extension on the Postgresql server.
Unfortunately, it seems that you cannot run the shp2pgsql command in the Azure Cloud Shell. It is just an interactive, browser-accessible shell for managing Azure resources. Not integrated with too much tool in it because of its flexibility. You can get more details about the features from the Features & tools for Azure Cloud Shell.
I suggest if you want to do something complicated, you'd better run it in a specific Azure VM for yourself. Hope this will be helpful to you.

Call x64 Powershell SQL snap-in from x86 Powershell

I need to create a script that reads some Access DBs and writes some values into a SQL Server DB.
Since I have Office 32 bits installed, I can only install the 32 bit Access provider.
But I want to use the SQL Server snap-ins to run the SQL commands, which are 64 bits.
Now, how can I combine both ? I need to run an Access query using Powershell x86, and send the fetched data to Powershell x64 so that it can insert it to SQL Server.
The only solution I see is dropping the SQL snap-ins, and re-writing the SQL wrappers myself, but that's just sad.
It turns out that the SQL Server snap-ins are outdated, and have been replaced with the SQLPS module.
The latest SQLPS version can be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=35580 (select the PowerShellTools.msi you need).
After installing x86\PowerShellTools.msi, the SQLPS module is available from x86 PowerShell, and has the same features as the "old" add-in (Invoke-SqlCmd...)