Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Question about Sql Accounts and Deletion Management

Posted on 2016-09-21
1
Medium Priority
?
77 Views
Last Modified: 2016-09-23
Question about Sql users.  I have a sql user that is added in the security section of the actual database.  I have the same user located in the instance level of security.  I deleted the user at the instance level but the user remained at the database level.  What is the proper way to delete a user if I totally want to rid the instance and all databases of this user login.

Also, all of the users in question should not be a owner of the database.

Question.... is there any danger in data being inaccessible after deletion of these users.

also, if i happen to delete a database owner..... i can always reassign that role to another user from an SA login.... Please verify.
0
Comment
Question by:jamesmetcalf74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
Vitor Montalvão earned 2000 total points
ID: 41808899
I have a sql user that is added in the security section of the actual database.  I have the same user located in the instance level of security.  I deleted the user at the instance level but the user remained at the database level.  
That's because the first is a SQL Login and the second a Database User.

What is the proper way to delete a user if I totally want to rid the instance and all databases of this user login.
Proper way is to delete both (Login and database user).
DROP LOGIN <loginName>
GO
USE databaseName
DROP USER <userName>

Open in new window


Question.... is there any danger in data being inaccessible after deletion of these users.
For user that user won't be able to access the data anymore but others users still can. Just be sure you let at least one login with sysadmin server role to fix the things if needed.

also, if i happen to delete a database owner..... i can always reassign that role to another user from an SA login
True. For that run the following:
USE DatabaseName
EXEC sp_changedbowner 'UserName'

Open in new window

1

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question