SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Shrink Log File to Target Percentage


Shrink Log File to Target Percentage

Author
Message
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
Comments posted to this topic are about the item Shrink Log File to Target Percentage

Tommy

Follow @sqlscribe
hannesm
hannesm
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 26
This seems to be a great piece of work....
One question though - it seems as if there is a line missing after the last checkpoint ???

    
if (select cast(databasepropertyex(db_name(), 'recovery') as varchar(10))) = 'FULL'
    begin
     set @backup_file_name = upper(db_name()) + '_Log_' + replace(replace(replace(convert(varchar(50), getdate(), 120), '-', ''), ' ', ''), ':', '') + '.lbk'
     set @sql = 'backup log ' + @database_name + ' to disk = ''' + @backup_log_file_path + @backup_file_name + ''' '
     exec sp_executesql @sql
     set @sql = 'checkpoint'
    end


:-)
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
This is an artifact of copy and paste Smile You can safely comment out the "set @sql = 'checkpoint'" after the backup. It won't do any harm in however I'll be sure to post a new revision without it - good catch!

Tommy

Follow @sqlscribe
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
Just FYI - procedure has been updated on SSC to account for checkpoint (previous post).

Tommy

Follow @sqlscribe
dlucas-615847
dlucas-615847
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 39
When I try to creat this stored procedure, I get two syntax errors:

Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 107
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 111
Incorrect syntax near '#results'.

I'm not sure why.
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
dlucas-615847 (9/19/2009)
When I try to creat this stored procedure, I get two syntax errors:

Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 107
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 111
Incorrect syntax near '#results'.

I'm not sure why.


I can't seem to reproduce it but check the quotes ('). I've run into some problems with the WYSWYG editor on SSC when uploading scripts. You can e-mail me at tbollhofer2@gmail.com if you continue to have problems and I'll send you a copy. I've been running this in production for some time now.

Thanks Smile

Tommy

Follow @sqlscribe
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
Tommy Bollhofer (9/20/2009)
dlucas-615847 (9/19/2009)
When I try to creat this stored procedure, I get two syntax errors:

Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 107
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 111
Incorrect syntax near '#results'.

I'm not sure why.


I can't seem to reproduce it but check the quotes ('). I've run into some problems with the WYSWYG editor on SSC when uploading scripts. You can e-mail me at tbollhofer2@gmail.com if you continue to have problems and I'll send you a copy. I've been running this in production for some time now.

Thanks Smile


Update: I can reproduce this by copying the T-SQL from SSC so I'm assuming this is related to the WYSWYG editor. I just uploaded a new version which should post later this afternoon or sometime tomorrow morning. If this continues to be a problem I will reach out to Steve Jones to see if we can add a resource section so that the procedure can be downloaded directly.

In the interim, please feel free to e-mail me at tbollhofer2@gmail.com and I'll e-mail you a copy.

Thanks!

Tommy

Follow @sqlscribe
Tommy Bollhofer
Tommy Bollhofer
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2234 Visits: 3359
Tommy Bollhofer (9/21/2009)
Tommy Bollhofer (9/20/2009)
dlucas-615847 (9/19/2009)
When I try to creat this stored procedure, I get two syntax errors:

Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 107
Incorrect syntax near ' '.
Msg 102, Level 15, State 1, Procedure usp_maintain_database_log, Line 111
Incorrect syntax near '#results'.

I'm not sure why.


I can't seem to reproduce it but check the quotes ('). I've run into some problems with the WYSWYG editor on SSC when uploading scripts. You can e-mail me at tbollhofer2@gmail.com if you continue to have problems and I'll send you a copy. I've been running this in production for some time now.

Thanks Smile


Update: I can reproduce this by copying the T-SQL from SSC so I'm assuming this is related to the WYSWYG editor. I just uploaded a new version which should post later this afternoon or sometime tomorrow morning. If this continues to be a problem I will reach out to Steve Jones to see if we can add a resource section so that the procedure can be downloaded directly.

In the interim, please feel free to e-mail me at tbollhofer2@gmail.com and I'll e-mail you a copy.

Thanks!


The new version has been posted to SSC. I've tested and verified everything is working. To avoid any formatting issues; i.e. UNICODE, etc., I would recommend copying and pasting the code into SSMS.

Thanks!

Tommy

Follow @sqlscribe
Iwas Bornready
Iwas Bornready
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16420 Visits: 885
Thanks for the script.
dlucas-615847
dlucas-615847
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 39
That did the trick. Thanks.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search