SQL Server database file not being truncated -


i have database ~4gb in size. i've copied database , deleted 99% of data on because need database schema , basic data (mostly static data kept).

the problem mdf file still ~4gb in size. if read size of tables (using this, example), sum less 20 mb together. log file shrunk, none of scripts ran worked shrinking db file.

note: don't this, time need shrink database (i know it's not recommended)

edit: +useful info

command:

exec sp_spaceused 

output:

database_name       database_size   unallocated_space accudemiaemptydb    3648.38 mb      4.21 mb 

command:

select object_name(id) objname, sum(dpages*8) dpages, count(*) cnt sysindexes group id order dpages desc 

output:

object_name(id)            sum(dpages*8)    count(*) sysdercv                   675328           1 sysxmitqueue               359776           1 sysdesend                  72216            1 sysconvgroup               47704            1 sysobjvalues               4760             5 sec_operationaccessrule    3472             5 sec_pageaccessrule         2232             5 syscolpars                 656              11 auditobjects               624              2 sysmultiobjrefs            408              5 helppage                   376              8 sysschobjs                 352              9 syssoftobjrefs             328              7 sysidxstats                272              10 sysrscols                  200              1 translation                160              3 sysallocunits              128              3 sysiscols                  128              8 syssingleobjrefs           96               5 sysrowsets                 80               4 

first run

exec sp_spaceused 

within database check how can recover. if find shows no space unused, have misunderstood space allocation.

this how shrink test1 db, playpen stackoverflow queries. cut 3gb down 8mb.

use test1; exec sp_spaceused; checkpoint; alter database test1 set recovery simple; alter database test1 set recovery full; dbcc shrinkfile(1,1); dbcc shrinkfile(2,1); 

for it's worth, use check allocation size table. maybe checking incorrectly? includes indexes.

select object_name(id), sum(dpages*8), count(*) sysindexes group id 

edit - based on tables hogging space edited question

martin's comment moved answer: tables involved service broker conversations. http://social.msdn.microsoft.com/forums/en/sqlservicebroker/thread/03180f45-cd83-4913-8f0e-3d8306f01f06 link has workaround.

there alternative; using cut down database

  1. generate script - objects - include options (keys, fulltext, defaults etc)
  2. include option script data
  3. create new db , populate scripts

(from recollection, sssb queues not included in generate-data scripts)


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -