Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.database_files

  No additional text.


Syntax
CREATE VIEW sys.database_files AS
	SELECT
		file_id 				= f.fileid,
		file_guid 				= f.fileguid,
		type					= f.filetype,
		type_desc			= ft.name,
		data_space_id 		= f.grpid,
		name 				= f.lname,
		physical_name 		= f.pname,
		state				= convert(tinyint, case f.filestate		-- Map enum EMDFileState to AvailablityStates
								when 0 then 0 when 10 then 0	-- ONLINE
								when 4 then 7	-- DEFUNCT
								when 5 then 3 when 9 then 3	-- RECOVERY_PENDING
								when 7 then 1 when 8 then 1 when 11 then 1	-- RESTORING
								when 12 then 4	-- SUSPECT
								else 6 end),	-- OFFLINE
		state_desc			= st.name,
		size 					= isnull(FilePropertyById(f.fileid, 'size'), size),
		max_size 			= f.maxsize,
		f.growth,
		is_media_read_only 	= sysconv(bit, f.status & 8),		-- FIL_READONLY_MEDIA
		is_read_only 			= sysconv(bit, f.status & 16),	-- FIL_READONLY
		is_sparse 			= sysconv(bit, f.status & 256),	-- FIL_SPARSE_FILE
		is_percent_growth 	= sysconv(bit, f.status & 32),	-- FIL_PERCENT_GROWTH
		is_name_reserved		= sysconv(bit, case f.filestate when 3 then 1 else 0 end), -- x_efs_DroppedReusePending
		create_lsn			= GetNumericLsn(f.createlsn),
		drop_lsn				= GetNumericLsn(f.droplsn),
		read_only_lsn			= GetNumericLsn(f.readonlylsn),
		read_write_lsn		= GetNumericLsn(f.readwritelsn),
		differential_base_lsn	= GetNumericLsn(f.diffbaselsn),
		differential_base_guid	= f.diffbaseguid,
		differential_base_time	= nullif(f.diffbasetime, 0),
		redo_start_lsn			= GetNumericLsn(f.redostartlsn),
		redo_start_fork_guid	= f.redostartforkguid,
		redo_target_lsn		= GetNumericLsn(f.redotargetlsn),
		redo_target_fork_guid	= f.forkguid,
		backup_lsn			= GetNumericLsn(f.backuplsn)
	FROM sys.sysprufiles f
	LEFT JOIN sys.syspalvalues st ON st.class = 'DBFS' AND st.value = f.filestate
	LEFT JOIN sys.syspalvalues ft ON ft.class = 'DBFT' AND ft.value = f.filetype
	WHERE filestate NOT IN (1, 2)	-- x_efs_Dummy, x_efs_Dropped

 
Last revision 2008RTM
See also

  sp_clean_db_file_free_space (Procedure)
sp_clean_db_free_space (Procedure)
sp_helpdistributiondb (Procedure)
sp_help_fulltext_catalogs (Procedure)
sp_help_fulltext_catalogs_cursor (Procedure)
sp_sysutility_ucp_calculate_filegroups_with_policy_violations (Procedure)
sysutility_ucp_dac_database_file_space_utilizations (View)
sysutility_ucp_database_files (View)
sysutility_ucp_mi_database_file_space_utilizations (View)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash