|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 4:40 AM
Points: 711,
Visits: 212
|
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, June 13, 2011 11:45 AM
Points: 221,
Visits: 55
|
|
Thanks for the script, but I cannot think of any normal DBA use for it. It is not recommended to shrink all of the databases on a time to time basis. This because of the fragmentation you get on your filesystem. It is recommended to disable the shrink option and size your databases before you place them on the server. Fragmentation will make your server slower.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, March 20, 2013 10:58 AM
Points: 4,
Visits: 54
|
|
The problem that I have is the logfile growing out of control.
I like the script but I found that the shrink (from the GUI) didn't work unless you shrink file as opposed to database. Also when you shrink file you must shrink the log file.
I still can not fathom why MS has changed the shrink so that you must be in simple mode to shrink the logfile. I am used to Oracle, NZ, and TD where this problem just doesn't exist.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, November 30, 2010 11:03 AM
Points: 70,
Visits: 31
|
|
Hi,
I think that's the issue isn't only the usefulness of the script. The script itself it's ugly :p
Actually, you should be getting first the recovery mode of the DB and after the shrink, you should set it again to the original mode. Also, there is a undocummented SP to LOOP over the DBs.
SP_MSForEachDB
Identically to that, there is another to loop through the tables on the current DB:
SP_MSForEachTable
Both of them have a LOT of useful parameters. Take a look at them.
Cheers, Gonzalo
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Monday, June 17, 2013 10:19 AM
Points: 1,910,
Visits: 1,606
|
|
One more thing that's wrong with this - switching to SIMPLE breaks the log backup chain so you lose the ability to do point-in-time recovery. I have no idea why the script needs to switch to SIMPLE - the shrink (although completely not recommended) will work fine in FULL as well - if the author was trying to prevent log files growing, he just needed to mention taking log backups rather than taking the drastic mode of switching to SIMPLE. No enterprise in their right mind is going to use SIMPLE...
Paul Randal CEO, SQLskills.com: Check out SQLskills online training! Blog:www.SQLskills.com/blogs/paul Twitter: @PaulRandal SQL MVP, Microsoft RD, Contributing Editor of TechNet Magazine Author of DBCC CHECKDB/repair (and other Storage Engine) code of SQL Server 2005
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 2:51 AM
Points: 6,
Visits: 43
|
|
Strange that this script is mentioned in the newsletter. The editor should not has permitted this script since it's a bad bad bad practice.
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Tuesday, November 30, 2010 11:03 AM
Points: 70,
Visits: 31
|
|
That's true, scheduled or regular shrink is a bad practice, in paper.
Sometimes there isn't enough time to fix the App and we need to solve things on the run. Change an app architecture could take months... sometimes a DBA must bend some "best practices" to keep things smooth enouth for the business.
Cheers, Gonzalo
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Monday, June 13, 2011 11:45 AM
Points: 221,
Visits: 55
|
|
gonzaloaguilar (3/17/2008) That's true, scheduled or regular shrink is a bad practice, in paper.
Sometimes there isn't enough time to fix the App and we need to solve things on the run. Change an app architecture could take months... sometimes a DBA must bend some "best practices" to keep things smooth enough for the business.
Cheers, Gonzalo I agree with your point, but therefore shrinking all databases is not a good solution. You should then, and only if no other options are available, shrink only those databases that are giving trouble. If all databases are having trouble... Very bad design of all the databases...
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Sunday, December 16, 2012 4:48 AM
Points: 150,
Visits: 118
|
|
While shrinking each database in a production environment wouldn't be recommended, this does come in handy if you need to rein in your DBs on local or dev. Who here hasn’t had several runaway logs after some over eager developers were done with a particular server???
This sets the backup point on the logs so they can be shrunk. It then returns both the log and data files to their original sizes if possible.
DECLARE @cmd1 varchar(2000), @cmd2 varchar(2000)
SET @cmd1 = 'BACKUP LOG [?] WITH NO_Log' SET @cmd2 = 'DBCC SHRINKDATABASE ([?],TRUNCATEONLY)'
EXEC sp_msforeachdb @command1 = @cmd1, @command2 = @cmd2
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 18, 2012 7:50 AM
Points: 5,
Visits: 98
|
|
| I agree with most, if not all on this topic. I made it as far as "changes all databases' recovery mode to simple" and quit reading further.
|
|
|
|