Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 truncate data file

Author  Topic 

amy
Starting Member

30 Posts

Posted - 2002-06-17 : 14:32:01
What I mean is I want to shrink the databatase or truncate the datafiles to have more the space for database

izaltsman
A custom title

1139 Posts

Posted - 2002-06-17 : 15:43:00
First of all, there is no such thing as truncating a datafile.
You can shrink it (see DBCC SHRINKFILE in BOL), but then you will have LESS space for your database.
If you want to increase the amount of space reserved for the database, you can
1. Increase the size of the datafile. The command would look something like:

ALTER DATABASE mydb MODIFY FILE (NAME = mydatafile, SIZE = 100MB)

You could also allow SQL Server to automatically expand your datafile by setting MAXSIZE property to UNLIMITED.

2. Add another datafile.

ALTER DATABASE mydb ADD FILE
(
NAME = moredata,
FILENAME = 'd:\moredata.ndf',
SIZE = 100MB
)





Edited by - izaltsman on 06/17/2002 15:43:36
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2002-06-17 : 15:43:15
Look up in the books online:

DBCC SHRINKDATBASE: Shrinks the size of the data files in the specified database.

DBCC SHRINKFILE: Shrinks the size of the specified data file or log file for the related database.


Michael

If I recall, Depending on how large your database is, your computer specs, and what options you select, this may take a rather long time, maybe several hours. I suggest doing this "after-hours" so that it doesn't bring your DB to it's knees.





Go to Top of Page
   

- Advertisement -