Knowledge Base

Search Knowledge Base

KB #240094: How to capture output of sp_n_enumfiles into a table



API sp_n_enumfiles gives a report of encrypted database files currently attached to SQL Server. This KB Article gives instructions on how to capture the result set into a table.


Additional Information:
The following example puts the result set of sp_n_enumfiles into a temporary table named #dbfiles and checks to see if any files containing the name ‘northwind’ are included

Create Table #dbfiles(dbfile varchar(128))
Insert #dbfiles EXEC sp_n_enumfiles
select dbfile from #dbfiles
IF EXISTS (SELECT dbfile FROM #dbfiles WHERE dbfile like '%northwind%') begin
  select 'northwind found'
drop table #dbfiles

Last modified: 1/13/2016