Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

Persistancy of user account & its permission in TempDB

$
0
0

Hi,

I have observed an interesting issue in sql server 2012 (my version is 11.0.5532)

1. Create a sql server login, let's call it [Test]

2.Create a user (let's call it TestUser) in TEMPDB with the following script

USE [tempdb]
GO
CREATE USER [TestUser] FOR LOGIN [Test] WITH DEFAULT_SCHEMA=[dbo]
ALTER ROLE [db_datareader] ADD MEMBER [TestUser]
ALTER ROLE [db_datawriter] ADD MEMBER [TestUser]
GO

Now reboot the server, and since TempDB will be recreated during sql service restarts, I expect the newly created TestUser in tempdb to be disappeared. But it does not, it is still there.

Now, let's create another user, this user will matching an existing Windows Login account in the sql server, 

USE [tempdb]
GO
CREATE USER [TestUser2] FOR LOGIN [MyDomain\XXX] WITH DEFAULT_SCHEMA=[dbo]
ALTER ROLE [db_datareader] ADD MEMBER [TestUser2]
ALTER ROLE [db_datawriter] ADD MEMBER [TestUser2]
GO

and reboot the server again, this time, in TempDB, TestUser2 disappears (as expected) while the original TestUser still persists.

In summary, in TempDB, if I create a user with a regualr sql login and also create another user with a windows login, after sql server restarts, the user with the sql login will still exist in tempdb while the one with the windows login will disappear.

Does anyone know why this is the case?

Thanks,

Jeff_yao


Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>