Moved database to new instance - permission issues - sql-server

I had to upgrade SQL server Express from 2017 to 2019. I have some tables that I backed up from the old instance and restored to the new instance. I then recreated the user I needed in the new instance with the same privileges. It seems I can login as that user but I cannot access the table.
If I try to edit that user's table privileges in "NewInstanceName -> Logins -> UserName" I get the message"
Create failed for User 'toolLocation'. (Microsoft.SqlServer.Smo)
User, group, or role 'toolLocation' already exists in the current
database. (Microsoft SQL Server, Error: 15023)
How do I resolve this?

Related

Unable to access an SQL Server database created via Plesk in SQL Server 2014 Management Studio

In Plesk v12.5.30, I have created a new SQL Server database named ngo_database and a new database user called ngo_databaseuser.
I can connect to this new database via Navicat for SQL Server v12.1.20 (after providing host “xxx” + user name “ngo_databaseuser” + password + initial database “ngo_database”), And I am able to access “ngo_database” database and create new tables and queries.
But when I try to connect via SSMS 2014 (after providing server name “xxx” + login “ngo_databaseuser” + password + connect to database “ngo_database”), I am not able to access “ngo_database” database and the only databases available are master + tempdb. And I am not able to import nor create a new user database.
BTW, I have checked with the hosting company and the “Grant the ALTER DATABASE permission to all Microsoft SQL Server database users” is checked.
What I am doing wrong and why I can’t access the database via SSMS?
Not being a see a database in the object explorer of SSMS does not equate to not being able to access it. When you can only see the databases master and tempdb this very likely means that either you have had a DENY permission for VIEW ANY DATABASE added to your login, or a Server Role it belongs to, or VIEW ANY DATABASE has been revoked from the public role and you haven't been granted it.
SSMS builds the list in the object explorer by using the sys objects, and without VIEW ANY DATABASE, it can't see the databases you have access to to retrieve the relevant objects from it.
You can check if you have access to the database by using USE {Your Database} or trying to query a table (such as SELECT * FROM {Your Database}.sys.objects;).
If you need the VIEW ANY DATABASE permission, you need to speak to your DBA.

Cannot create a new database in Sql Server - changed username

I installed Sql Server on a server in a company I used to work for.
I left the company - and rejoined a year later - and now I have a different domain login.
I've logged on to the server again, and in SSMS tried to create a new database - however I get the error:
create database permission denied in database 'master'
I have tried changing permission and adding DBCreator to BuiltInUsers and to SA - and also tried adding my new domain name to the security section - but when I try to add DBCreator to my user name, I get the error:
Cannot alter the server role 'dbcreator' because it does not exist or you do not have permission
Is there any way I can take control of the Sql Server instance again, to allow me to create new databases?
Thanks for any help,
Mark
I faced this problem when I made another SQL user which I login with, and I tried to give this user [dbcreator] grant.
I solved this via
runnig sql server as administrator
switching to my windows authentication.
going to folder Security -> Logins and double click on my new sql login user.
selecting Server roles and give grant to my user.

User permissions in remote SQL Server

I have connection with my database in SQL Server Management Studio from remote server somee.com. I want to change permissions for user (security -> users) and add permissions to update, insert. Every permission I add
is disappearing if I reopen the window database user
What's the problem? I can't edit data :(

User or role does not exist in the database

I am trying to locally install a CMS for my website. During this installation process, it shows me an error "User or role does not exist in the database.
Screenshot of the error:
Here's the screenshot of the database properties from Management Studio.
How can I add a new role or user to this database?
Within SQL Server Management Studio
Expand the Security node
Right-click the Logins node and select New Login...
Provide a login name and password (SQL authentication) or a logon name only if using Windows authentication.
Click User Mapping in the "Select a page" box on the left.
Check the database dbemployee in the list.
Grant the appropriate security in the database role membership.
Hit OK and you should be good to go.

Problem restoring a SQL Server backup

I have a SQL Server 2008, which is part of a domain. Now I make a backup of a database of this server and restore it on a SQL Server, which is not part of a domain.
I have an C# application, which uses this database. On the NON-Domain machine I get now exceptions like this:
"Cannot execute as the database prinzipal because the principial "dbo" does not exist, this type of principal cannot be impersonatedm or you don not have the permission"
I think, the problem is, that the database owner is a domain user and this user doesn't exist on the target machine (backup machine)!? How can I solve this ?
The MS SQL server follows a 2 layer user system.
You must make sure that your login is an actual login on the SQL Server (this refers to the SQL Server itself NOT to the actual database).
You find the SQL Server users in the Management Studio under:
Server root -> Security - Logins
After you ensured that your login is available you have to map it to a user/schema. In Order todo so you must:
Select the SQL Server user you want to map
Right click on the user
Select properties
Switch to the User Mapping tab
Choose the database you want to create a mapping for
Select the Database user you want to associate the currently selected SQL Server user with
Done

Resources