Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Script which will shrink all databases, please

Author  Topic 

anxcomp
Starting Member

41 Posts

Posted - 2007-08-09 : 12:40:34
Hi,

May somebody send script which will shrink all databases on server (SQL 2005). I think about DBCC SHRINKFILE and DBCC SHRINKDATABASE.

I need do this at many servers, so I can't do this manually.

Thanks



--
Regards
anxcomp

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-09 : 13:16:42
script library is a forum for posting working scripts only.
moved from script library.

and shrinking databases is a bad thing.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-08-09 : 13:36:57
This will shrink a single database file. I'm sure you can figure out how to do the rest.

Shrink DB File by Increment to Target Free Space
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=80355




CODO ERGO SUM
Go to Top of Page

anxcomp
Starting Member

41 Posts

Posted - 2007-08-09 : 14:02:53
Thanks for help, I've seen this post yet. This script shrink database file, but i need shrink log file (.LDF). Could tell me how modify this script, please. And how use it to all database log files on server?


--
Regards
anxcomp
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-09 : 22:35:06
Specify log file name or id in the script.
Go to Top of Page

anxcomp
Starting Member

41 Posts

Posted - 2007-08-10 : 03:15:37
Hi,

Thanks, do you mean set

"@DBFileName = 'MyDatabaseFileName'" as set @DBFileName = 'MyDatabaseLOGFileName'?

--
Regards
anxcomp
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-11 : 00:54:01
That's correct.
Go to Top of Page

anxcomp
Starting Member

41 Posts

Posted - 2007-08-11 : 07:32:55
Thanks rmiao, I'll tray this

--
Regards,
anxcomp
Go to Top of Page
   

- Advertisement -