Now there is a non-documented Stored Procedure on SQL Server that will let you run some SQL on each Database. A very handy stored proc, when I went and had a look a the back end of it however I felt it could be a bit better and simpler. So I made the below, its basically Dynamic SQL and I just pass in the Database and each SQL Command to run. There are 5 commands in total that you can feed in to run, 3 of these will run on each of the databases, the other two are a pre Command to run first and a post Command to run at the end of the process. There is a variable '?' which will be replaced with the current database name. This can be used to determine if the current database is to run the command or not. You can also alter the insert into the @DBs temp table if you wish to only ever use certain Databases if you choose. Example of use exec sp_foreachDB @Command1 = ' if ''?'' not like ''%master%'' begin select DB_NAME() end' ,@Command2 = 'PRINT ''?''' ,@Command3 = 'PRINT ''Ash Rocks''' ,@PreCommand = 'PRINT ''Starting App''' ,@PostCommand = 'PRINT ''Finished App'''
A Normalization Primer
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.
2003-01-13
18,599 reads