shrinking file size by deleteing data in image fields

shrinking file size by deleteing data in image fields

Post by Russ » Wed, 24 Dec 2003 18:21:05


I have an application that has a table that contains multiple small image files.  This table now needs to have it's images archived, but I wish to have the rest of the record remain.  I have set the image field data to 'null', and then proceeded to shrink the database.  No additional free space was reclaimed.

What i am really asking is how can i clean out field data on specific records and have the file size reduced because of less data in the file.  I have tried shrinking etc, but as of yet there is no way to regain that free area!

 
 
 

shrinking file size by deleteing data in image fields

Post by Jacco Schalkwij » Wed, 24 Dec 2003 18:40:19


Hi Russ,

You have to drop the image column and recreate it, or copy the table, drop
the old table and rename the new table with the old table's name (you can
easily generate a script for this with Enterprise Manager|Design Table). It
is the only way to reclaim the space used by image and text columns in SQL
Server 2000. DBCC DBREINDEX and DBCC INDEXDEFRAG won't work sadly enough.
Yukon will have this functionality though.

--
Jacco Schalkwijk
SQL Server MVP


Quote:> I have an application that has a table that contains multiple small image

files.  This table now needs to have it's images archived, but I wish to
have the rest of the record remain.  I have set the image field data to
'null', and then proceeded to shrink the database.  No additional free space
was reclaimed.
Quote:

> What i am really asking is how can i clean out field data on specific

records and have the file size reduced because of less data in the file.  I
have tried shrinking etc, but as of yet there is no way to regain that free
area!

 
 
 

shrinking file size by deleteing data in image fields

Post by Vlad Vissoultche » Wed, 24 Dec 2003 18:46:02


you might want to try to shrink the data/log files instead. try this script:






from   sysfiles
where   status & 0x40 <> 0


from   sysfiles
where   status & 0x40 = 0




note: this is working for a db with a single data file and a single t-log
file.

HTH,
</wqw>
p.s. put WITH NO_INFOMSGS after DBCC if you dont need the extra output


Quote:> I have an application that has a table that contains multiple small image

files.  This table now needs to have it's images archived, but I wish to
have the rest of the record remain.  I have set the image field data to
'null', and then proceeded to shrink the database.  No additional free space
was reclaimed.
Quote:

> What i am really asking is how can i clean out field data on specific

records and have the file size reduced because of less data in the file.  I
have tried shrinking etc, but as of yet there is no way to regain that free
area!
 
 
 

shrinking file size by deleteing data in image fields

Post by Russ » Wed, 24 Dec 2003 19:16:10


Shrinking does not seem to work.  I am running it thru the enterprise manager.  Would that explain why it doesn't work properly?
 
 
 

shrinking file size by deleteing data in image fields

Post by Andrew J. Kell » Wed, 24 Dec 2003 19:39:53


Try using the DBCC CLEANTABLE command and see if that helps.

--

Andrew J. Kelly
SQL Server MVP


Quote:> Shrinking does not seem to work.  I am running it thru the enterprise

manager.  Would that explain why it doesn't work properly?
 
 
 

shrinking file size by deleteing data in image fields

Post by Russ » Wed, 24 Dec 2003 21:46:06


Even if i am not dropping a field, but rather setting the data in the field to NULL?
 
 
 

shrinking file size by deleteing data in image fields

Post by Andrew J. Kell » Wed, 24 Dec 2003 22:44:20


Sorry about that, I got you confused with a similar posting.  No I don't
believe CLEANTABLE will do anything if your not dropping the column.  I
believe you need to bcp it in and out with the truncate or drop table
in-between to be sure to get it clean.

--

Andrew J. Kelly
SQL Server MVP


Quote:> Even if i am not dropping a field, but rather setting the data in the

field to NULL?
 
 
 

1. help -- shrink data file size

Hello,

SQL 7.0 sp 2

After archiving some data, I need to release the unused space in data
file to the system. e.g. DBCC SHRINKDATABASE and DBCC SHRINKFILE didn't
work well. Do I need to reorganize every tables on the datafile? Is
there any kind of scripts/commands to check which tables are at the end
of the data file so that I can move them to a different datafile?
something like dbcc loginfo(databasename)?

Thanks a lot,

Shu

Sent via Deja.com http://www.deja.com/
Before you buy.

2. 2nd Shift operator job in Chicago

3. Problem with determining the size of an image data field

4. Adding Zero's to values brought back from a SQL Query

5. DBCC Shrink File Bloating File Size

6. SQL Server 7.0 suddenly stops!!

7. Save File as image Field in SQL 7.0 - Why is size of field larger than the actual file size?

8. : Ingres RDBMS through ODBC and 1-2-3 client.

9. Display Image in picturebox from db image field without temp file

10. From image file to Image field

11. Physical Files in place of Image data fields

12. Shrinking data file and log file

13. writting image data to an image field