naTro
naTro

Reputation: 1

How can i shrink mdf file in SQL Server without error?

if i want to shrink one mdf file:

dbcc shrinkfile (N'xy');
go

i got error:

DBCC SHRINKFILE: Heap page 23:878847 could not be moved. The statement has been terminated. DBCC execution completed. If DBCC printed error messages, contact your system administrator. Msg 7105, Level 22, State 9, Line 1 The Database ID 20, Page (23:200140), slot 1 for LOB data type node does not exist. This is usually caused by transactions that can read uncommitted data on a data page. Run DBCC CHECKTABLE.

But if i run dbcc checkdb or checktable, it doesnt show me any error. Where can be problem? What should i do? Thank you.

Upvotes: 0

Views: 3236

Answers (2)

Nits Patel
Nits Patel

Reputation: 390

May This helps you

USE yourdatabaseName 
GO
DBCC SHRINKFILE (N 'yourdatabaseName', 3)
GO

Upvotes: 0

mhd.cs
mhd.cs

Reputation: 721

your Must Put Your Database In simple Mode and After That shrink your database and Then put your database in Recovery Full Mode

Alter Datatbase yourdatabaseName Set recovery simple 
Go
DBCC ShrinkFile (yourdatabaseName ,5)
GO
Alter Database yourdatabaseName  Set Recovery Full

Upvotes: 1

Related Questions