Getting permission denied while importing .bacpac file to amazone rds - sql-server

I am trying to import .bacpac file to one of my amazone RDS SQL server and I am getting the following error,
Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 15151, Level 16, State 1, Line 1 Cannot drop the user 'myuser', because it does not exist or you do not have permission.
Error SQL72045: Script execution error. The executed script:
DROP USER [myuser];
I am using sqlpackage command utility to import the .bacpac file. Here "myuser" is my rds master user name which was specified when I a creating the rds instance server.
Also, I would like to know how I can give full privilege to a user to a database in Amazone RDS SQL server.

Related

Attempt to retrieve data for object failed for Server (Microsoft.SqlServer.Smo)

I have two databases, one hosted in Azure SQL Server and another one which is local on my own SQL Server instance. Both of these I manage using SSMS.
I wanted to see how I can backup the Azure DB and restore it on the local instance (where I currently have other databases as well, generated and managed by Entity Framework) of my SQL Server. For that purpose, I followed this video.
What I basically did was to export a .bacpac file and restore it on my local instance by making a reference to "Import Data-Tier application".
Everything went well. The content was successfully restored and I was able to browse through it. When I finished with my testing I manually deleted this new database.
From that moment on, I can not access my other databases at all. When I try to do whatever SQL query on those I get the following error:
Attempt to retrieve data for object failed for Server '**********'. (Microsoft.SqlServer.Smo)
ADDITIONAL INFORMATION:
Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The connection is broken and recovery is not possible. The client driver attempted to recover the connection one or more times and all attempts failed. Increase the value of ConnectRetryCount to increase the number of recovery attempts. (Microsoft SQL Server, Error: 0)
Cannot open database "{THE NAME OF THE DB THAT I MANUALLY DELETED}" requested by the login. The login failed.
Login failed for user ******'. (Microsoft SQL Server, Error: 4060)

Can't restore Bacpac from Azure to local SQL server - fails when creating Hangfire Schema

Local SQL Server version: 2017 (v14.0.1000.169)
Remote Azure SQL server version: 12.0.2000.8
SQL Server Management Studio version: 14.0.17289.0 (v17.9.1)
Steps taken:
Export database from Azure SQL server using Tasks -> Export Data-tier Application (I have also tried excluding the Hangfire Schema)
Import database into Local SQL server using Tasks -> Import Data-tier Application
Getting this error:
Could not import package.
Warning SQL72012: The object [mydatabase20181127deploy_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [mydatabase20181127deploy_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: SQL Execution error: A fatal error occurred. The variable HangFireSchema could not be found.
Error SQL72045: Script execution error. The executed script:
CREATE SCHEMA [$(HangFireSchema)]
AUTHORIZATION [MyDatabase];
Error SQL72014: SQL Execution error: A fatal error occurred. Incorrect syntax was encountered while CREATE SCHEMA [$(HangFireSchema)] was being parsed.
Error SQL72045: Script execution error. The executed script:
CREATE SCHEMA [$(HangFireSchema)]
AUTHORIZATION [MyDatabase];
(Microsoft.SqlServer.Dac)

Azure SQL Server BACPAC import failed

whenever i try to import BACPAC on local sql server I am getting below error message:
TITLE: Microsoft SQL Server Management Studio
------------------------------
Could not import package.
Warning SQL0: The source contains users that rely on an external authentication provider that is not supported by the target. These users will be treated as users without logins.
Warning SQL72012: The object [DB_NAME_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [DB_NAME_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 33161, Level 15, State 1, Line 1 Database master keys without password are not supported in this version of SQL Server.
Error SQL72045: Script execution error. The executed script:
CREATE MASTER KEY;
(Microsoft.SqlServer.Dac)
------------------------------
BUTTONS:
OK
------------------------------
All the previously reported issues on SO are not same as this one. Does anyone faced the same issue before?
Try running this against your master database (right click on the server name in SSMS -> New Query)
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
After this, you can go through the import bacpac wizard again and the issue should be resolved.
Eventually I was able to resolve this issue by following option 2 suggested here
In nutshell,
Save the utility RemoveMasterKeyFrombacpac from here
Run the command .\RemoveMasterKey.ps1 -bacpacPath "C:\BacPacs\fileName.bacpac"
Once above command finishes we get the -patched bacpac which imported seamlessly.
Update
With new MS SQL Server 2016 (13.0.1745.2) and SSMS v17.6 this is not an issue anymore.

Create User To Run SQL Migration Script Azure SQL

Currently moving a database to Azure SQL. I've generated a script to import the database. In SQL management studio, I've connected to the cloud database as the server admin. I try to run the script - though I get multiple errors such as -
ODBC error: State: 28000: Error: 18456 Message:'[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user '##MS_InstanceCertificate##'.'.
Msg 5069, Level 16, State 3, Line 11
and
Looking around I found;
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-manage-logins
I went through the steps to create a user and add to the role dbmanager.
I'm still getting the same errors when running the database import script.
As a heads up, I've run this script logged in as the server admin and as the user created by the server admin.
Any help is greatly appreciated.
The error message is a bit misleading, it hasn't (necessarily) something to do with certificates. In general, this error message says that connecting to the database with a certain user failed. So check...
if the user exists
if the username is spelled correctly
if the database you connect to exists
if the database name is spelled correctly

Elevated Rights Error when trying to deploy SSIS packages to a remote server

this is a new staging server with SQL 2008. I'm not famliary with SSIS that much so trying to deploy a couple packages. So I do the following in BIDS..which is probably typical:
Right-click my solution, go to properties, then go to the deployment utility tab
Change CreateDeploymentUtility to true
Go and find the .SSISDeploymentManifest file locally on my machine
Run it and try to perform a SQL Server deployment to the customer's remote server (we're running vpn to get to it)
I put in the fully qualified remote server's name, my windows auth or SQL account (I tried both ways)
Try to click now the Package Path and get this:
TITLE: Package Installation Wizard
An OLE DB error 0x80040E09 (The EXECUTE permission was denied on the object 'sp_ssis_listpackages', database 'msdb', schema 'dbo'.) occurred while enumerating packages. A SQL statement was issued and failed.
ADDITIONAL INFORMATION:
An OLE DB error 0x80040E09 (The EXECUTE permission was denied on the object 'sp_ssis_listpackages', database 'msdb', schema 'dbo'.) occurred while enumerating packages. A SQL statement was issued and failed.
BUTTONS:
OK
So what do I do? How do I essentially run this as an administrator to get past this stupid elevated rights security error?
You should add your windows / sql account to sysadmin role.
In SQL Server Management Studio, go to Security -> Server Roles and double click sysadmin. Add your login and it should work when you try again.

Resources