vignesh
vignesh

Reputation: 1454

Remove existing log file and create new log file in sql server

I have log file which is grown to 1TB. I have no need of log file. Just want to delete the old log file and create a new one instead of old log file.

How can I achieve that ? will it cause any other problem? pleas help.

Upvotes: 5

Views: 25777

Answers (4)

I made a backup of the database (very important just in case something fails or trying something else you brake up things!) and then I detached and reatached the database, but deleting the ldf file from the reataching window. This creates a new ldf file as expected in the original database but empty.

enter image description here

More details here: https://inapp.com/delete-sql-server-database-transaction-log-file/

Upvotes: 1

Sajad
Sajad

Reputation: 1

use this :

create database cmsdb on
(filename = 'd:\programfiles\microsoft sqsl server \msql12.mssqlserver\mssql\data\cmsdb.mdf')
for attach_rebuild_log
go

Upvotes: 0

vignesh
vignesh

Reputation: 1454

Brought database to offline and deleted log file manually from file system. And bring database back to online. Thats worked out.

Upvotes: -2

Killer Queen
Killer Queen

Reputation: 796

Right mouse button on the database and

TASKS -> SHRINK -> FILES

Then choose the option that interests you

More :

https://learn.microsoft.com/en-us/sql/relational-databases/databases/shrink-a-file?view=sql-server-2017

Upvotes: 3

Related Questions