home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,854 of 19,505   
   Sonny to All   
   Needed to create a SQL script based on c   
   14 Apr 13 18:55:19   
   
   From: hairnhenna@gmail.com   
      
   I have a system which has 200+ databases and needed to run the following   
   script automatically on each one of them.   
   The 200 databases names can be found in the databasename coloum in the domain   
   table in one of the databases which is the system database.   
   So if I run the following script i get all the databases that I need to run   
   the scripts below on.   
      
   DEMOSYSTEM DB   
   select databasename from domain.   
      
   This gives me the names of the databases   
   eg.   
   DB1   
   DB2   
   DB3 etc etc.   
      
   The scripts then that I need to run on DB1, DB2, DB3 is as below   
      
   GO   
   CREATE USER [Master60SP] FOR LOGIN [Master60SP]   
   GO   
   ALTER USER [Master60SP] WITH DEFAULT_SCHEMA=[Master60SP]   
   GO   
   CREATE SCHEMA [Master60SP] AUTHORIZATION [Master60SP]   
   GO   
   EXEC sp_addrolemember N'db_datareader', N'Master60SP'   
   GO   
   EXEC sp_addrolemember N'MSDynamicsSL', N'Master60SP'   
      
   How can I create a script that will run the scripts as above on all the   
   databases whose names are in the domain tables/Coloum name Databasename   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca