Microsoft SQL Server Links

Links, articles, scripts, tips, and other technical sources for managing SQL Server. DBALinks is dedicated to SQL Server and database administration.

CHECK OUR BLOGS!

 

 
BLOGS Minimize
Print  
 
SEARCH BLOGS Minimize

Print  
 
DOWNLOADS... Minimize
Print  
 
BOOKS... Minimize

Print  
 
Advertisement Minimize

 

Print  
 
Database Files
Author: Aleksandar Tosic Created: Tuesday, October 23, 2007
Database Files

Truncating a data file

Truncating a data file

The following example truncates the primary data file in the AdventureWorks database. The sys.database_files catalog view is queried to obtain the file_id of the data file.

http://msdn2.microsoft.com/en-us/library/ms189493.aspx

USE AdventureWorks;
GO
SELECT file_id, name
FROM sys.database_files;
GO
DBCC SHRINKFILE (1, TRUNCATEONLY);

Comments (0)
By Aleksandar Tosic on Wednesday, October 15, 2008

How to empty a database file - Emptying a file

Emptying a file

The following example demonstrates the procedure for emptying a file so that it can be removed from the database. For the purposes of this example, a data file is first created and it is assumed that the file contains data.

http://msdn2.microsoft.com/en-us/library/ms189493.aspx

USE AdventureWorks;
GO
-- Create a data file and assume it contains data.
ALTER DATABASE AdventureWorks
ADD FILE (
    NAME = Test1data,
    FILENAME = 'C:\t1data.ndf',
    SIZE = 5MB
    );
GO
-- Empty the data file.
DBCC SHRINKFILE ('Test1data', EMPTYFILE);
GO
-- Remove the data file from the database.
ALTER DATABASE AdventureWorks
REMOVE FILE Test1data;
GO

Comments (0)
By Aleksandar Tosic on Wednesday, October 15, 2008

 
Announcements Minimize
SQL Server Service Pack Versions - Thursday, October 30, 2008
Version @@VERSION MsDtsSrvr.exe File Version Registry Version Registry Patch Level
Release to Manufacturing 9.00.1399.00 9.0.1399.0 9.0.1399.06 9.0.1399.06
Service Pack 1 9.00.2047.00 9.0.2047.0 9.1.2047.00 9.1.2047.00
Post SP1 Cumulative Hotfix 9.0.2153.00 9.0.2153.0 9.1.2047.00 9.1.2153
Service Pack 2 CTP 9.00.3027.00 9.0.3027.0 9.2.3027.00 9.2.3027.00
Service Pack 2 9.00.3042.00 9.0.3042.0 9.2.3042.00 9.2.3042
Service Pack 2 Rollup 3 9.00.3186.0 9.00.3186.00 9.2.3042.00 9.2.3186
 

Print