![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
In short, I'm trying to get the servername, databasename, userID and role from every SQL Server 2000, and load this information into one table on one |
|
Currently this is working with the script below, but I have a DTS package & job, along with a link to MAINSVR on each individual server. My QUESTION: how can I get this to run from MAINSVR with one job and one DTS package? I want to link all servers to the MAINSVR and run this script |
|
I appreciate your time and ideas! Thank you, ChelleV ------------------------ SET NOCOUNT ON DECLARE crs_Databases CURSOR FOR SELECT name FROM master..sysdatabases WHERE name not in('master','msdb','model','pubs','northwind','tem pdb') ORDER BY dbid DECLARE @str_Database varchar(40) CREATE TABLE #tbl_ARM ( tmb_ServerName varchar(25) NULL ,tmb_DBName varchar(40) NULL ,tmb_UserID varchar(25) NULL ,tmb_GroupID varchar(25) NULL ) OPEN crs_Databases FETCH NEXT FROM crs_Databases INTO @str_Database WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO #tbl_ARM --GET ALL ROLES FOR A USER EXEC('SELECT CONVERT(varchar(25),@@SERVERNAME) Servername ,' + '''' + @str_Database + '''' + ' ,CONVERT(varchar(25),su1.name) UserID ,CONVERT(varchar(25),su2.name) RoleID FROM [' + @str_Database + '].dbo.sysmembers INNER JOIN [' + @str_Database + '].dbo.sysusers su1 ON memberuid = su1.uid INNER JOIN [' + @str_Database + '].dbo.sysusers su2 on groupuid = su2.uid') FETCH NEXT FROM crs_Databases INTO @str_Database END CLOSE crs_Databases DEALLOCATE crs_Databases --GET ALL MEMBERS OF THE SYSADMIN ROLE INSERT INTO #tbl_ARM SELECT CONVERT(varchar(25),@@SERVERNAME) Servername ,sd.name DBName ,CASE WHEN sl.name IS NOT NULL THEN CONVERT(varchar(25),sl.name) ELSE CONVERT(VARCHAR(25), sl.loginname) END UserID ,'db_owner' FROM master.dbo.syslogins sl CROSS JOIN master.dbo.sysdatabases sd WHERE sysadmin = 1 insert into DSMNTAPPS02.DBManagement.dbo.RoleMembers ( mbr_Servername, mbr_DBname, mbr_MemberID, mbr_GroupID, row_created_date ) select tmb_ServerName, tmb_DBName, tmb_UserID, tmb_GroupID, getdate() from #tbl_ARM DROP TABLE #tbl_ARM |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Allan - thank you for your response. I have never used SQLDMO/ADO. Can you just give me some simple instructions on how to start looking into this |
|
Thanks! |
#5
| |||
| |||
|
|
Hi Allan - thank you for the detailed information. I am just getting started back on this task again, and am going to try this. I appreciate |
|
What is the name of your book? Is it available on amazon? |
![]() |
| Thread Tools | |
| Display Modes | |
| |