Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does MSSQL think of each ID corresponding to the role of a specific DB

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you the "MSSQL how to view the role of each ID corresponding to the specific DB", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how MSSQL views the role of each ID corresponding to the specific DB" this article.

Exec sp_MSforeachdb'insert into dbcenter..user_role_map ([DB_NAME], [uid], [uStatus], [uName], [rId], [rStatus], [rName]) select'?', a.uid as uid,a.status as uStatus,a.name as uName

B.uid as rId,b.status as rStatus,b.name as rName

From sysusers a left join sysmembers m on m.memberuid = a.uid

Left join sysusers b on b.gid = m.groupuid

Where a.issqluser = 1'

-- select substring (name, 1,70) 'Login Name',dbname from master..syslogins

-- relationship between users and roles

USE [DBCenter]

GO

-- drop table [DBCenter]. [DBO]. [user _ role_map]

CREATE TABLE [dbo]. [user_role_map] (

[DB_NAME] [varchar] (20) NOT NULL

[uid] [int] NULL

[uStatus] [int] NULL

[uName] [sysname] NOT NULL

[rId] [int] NULL

[rStatus] [int] NULL

[rName] [sysname] NULL

) ON [PRIMARY]

Use master

Go

Exec sp_MSforeachdb

'insert into dbcenter..user_role_map ([DB_NAME], [uid], [uStatus], [uName], [rId], [rStatus], [rName])

Select'?' As db_name,a.uid as uid,a.status as uStatus,a.name as uName

B.uid as rId,b.status as rStatus,b.name as rName

From sysusers a left join sysmembers m on m.memberuid = a.uid

Left join sysusers b on b.gid = m.groupuid

Where a.issqluser = 1'

Go

Select * from dbcenter..user_role_map

The above is all the content of this article entitled "how does MSSQL view the role of each ID corresponding to a specific DB". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report