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 2008 Forums
 Transact-SQL (2008)
 Truncate_Only equivalent in SQL 2008?

Author  Topic 

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2010-11-04 : 16:44:38
Hi All,

In SQL Server 2005, I used to use the following script with Truncate_Only all the time to shrink the database. Truncate_Only is not recognizable in SQL 2008. To the below script, what would be the exact equivalent script in SQL 2008? Please suggest.


Use ABC_Database
DBCC SHRINKFILE ('ABC_Database_Log', 1)
BACKUP LOG ABC_Database with TRUNCATE_ONLY
DBCC SHRINKFILE ('ABC_Database_Log', 1)

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-11-04 : 17:09:41
Did you check Books Online for the syntax?

Do you know that shrinking your database causes fragmentation?
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-04 : 18:24:03
Switch to Simple recovery model. If you don't need point in time recovery (and running that all the time indicates you don't or need but don't have in place), leave it in simple recovery.

If you're doing that 'all the time', I respectfully suggest that you have no idea how to properly maintain a database.
Please read through this - [url]http://www.sqlservercentral.com/articles/64582/[/url]

p.s. None of those statements shrink a database, the first and last shrink the transaction log

--
Gail Shaw
SQL Server MVP
Go to Top of Page

zeeshan13
Constraint Violating Yak Guru

347 Posts

Posted - 2010-11-05 : 07:59:53
It is already set to simple recovery. All I want to know is to how to reduce by database log size (.LDF)? Please suggest. Thank you all.
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-11-05 : 08:13:37
Why? Once off shrink or repeated operation?

If it's in simple recovery then there is absolutely no need for you to be running BACKUP LOG ABC_Database with TRUNCATE_ONLY as it would do effectively nothing (if it was a valid operation). Please go and read through that article.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -