August 25, 2005 at 11:26 am
Hello everybody,
I created this cursor in order to find data and log (.mdf and .ldf) files for each database on the server .So far I can see all Data files (.mdf) from master.sysdatabases , but can not find ALL logs in one place like Data files, only inside the each database. So, I created this to see them all at once :
declare DBName_cursor cursor
for
select name from master..sysdatabases
declare @name varchar (50)
declare @sql nvarchar(279)
open DBName_cursor
fetch next from DBName_cursor into @name
WHILE @@FETCH_STATUS = 0
begin
set @sql = 'use ' + quotename(@name) + ' select name, filename from sysfiles order by fileid'
FETCH NEXT FROM DBName_cursor into @name
end
CLOSE DBName_cursor
DEALLOCATE DBName_cursor
Now, I am thinking, is it possible to put everything from that cursor into one table to be able to make search or update or anything else I need with this data.
Maybe another Cursor inside this Cursor....? (just guessing...:confused
Thank you people!
August 25, 2005 at 11:51 am
i think you can get everything you might want straight from master:
select db_name(dbid),name, filename from master.dbo.sysaltfiles order by db_name(dbid)
Lowell
August 25, 2005 at 1:20 pm
Thank you! I did not look at that table at all, just checked sp_helpfile and sp_helpdb trying to find where the files name are coming from silly me
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply