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 Administration (2000)
 primary data file

Author  Topic 

kish
Starting Member

45 Posts

Posted - 2004-03-04 : 06:59:43
Hi Gurus,

1. I have one primary data file and 4 secondary data files.
I need to find out which is my primary file by passing a sql query to the database. I know that the primary file has a .mdf extension, but is there any other way of finding out ?

2. How can I find out that a particular table belongs to a particular filegroup ? Is there info. available in any of the sys tables.

Thanks

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2004-03-04 : 07:52:04
quote:
Originally posted by kish

Hi Gurus,

1. I have one primary data file and 4 secondary data files.
I need to find out which is my primary file by passing a sql query to the database. I know that the primary file has a .mdf extension, but is there any other way of finding out ?



Thanks






select * from master..sysaltfiles where dbid in (select dbid from master..sysdatabases where name='databasename') and fileid=1 and groupid=1

He is a fool for five minutes who asks , but who does not ask remains a fool for life!
Go to Top of Page

kish
Starting Member

45 Posts

Posted - 2004-03-04 : 08:00:46
thanks a lot for the answer.

If i have a filename and i need to find out that if the particular file is a primary file, then I can use the following query :

select * from sysaltfiles where filename like '%model%' and groupid=1

I hope I am right.
Go to Top of Page
   

- Advertisement -