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.
Author |
Topic |
Madhav
Starting Member
38 Posts |
Posted - 2007-07-06 : 06:55:51
|
hi all ,i want two data files data1.mdf and data2.mdfin my database called 'data'.i had some 100 tables, 100 views in my data base.I want to know which table is in which datafile.is there any procedure to find out this.help me guys. |
|
b.veenings
Yak Posting Veteran
96 Posts |
Posted - 2007-07-06 : 07:21:37
|
right click on a table in EM and choose properties there is shown on wich filegroup the table is located.i would also say select * from sysobjects but i can't get any info from that table but there is your objects overhead.Need an SQL consultant?check www.veeningsengineering.nl |
 |
|
Madhav
Starting Member
38 Posts |
Posted - 2007-07-06 : 07:49:00
|
thanks,but it is same as sp_help <table_name>.is there any other way to see what tables are there in a file group.quote: Originally posted by b.veenings right click on a table in EM and choose properties there is shown on wich filegroup the table is located.i would also say select * from sysobjects but i can't get any info from that table but there is your objects overhead.Need an SQL consultant?check www.veeningsengineering.nl
|
 |
|
kishore_pen
Starting Member
49 Posts |
Posted - 2007-07-06 : 08:44:21
|
Hi Madhav,Can you try the following way:-- Code Startsdeclare @ObjId int, @RCnt int, @Cnt int, @FGName varchar (128)-- Creating temp. tabledeclare @Result table( ObjID int, ObjName sysname, Type char (2), FGName varchar (128))begin insert into @Result (ObjID, ObjName, Type) select Id, Name, XType from dbo.Sysobjects with (nolock) where xtype in ('U', 'V') -- user tables & views select @Cnt = 1 , @RCnt = 0 select @RCnt = count (*) from @Result while (@Cnt <= @RCnt) begin set rowcount @Cnt select @ObjId = ObjID from @Result order by objID set rowcount 0 select @FGName = s.groupname from sysfilegroups s with (nolock), sysindexes i with (nolock) where i.ID = @ObjID and i.indid < 2 and i.groupid = s.groupid update r set FGName = @FGName from @Result r where ObjID = @ObjId set @Cnt = @Cnt + 1 end select * from @Resultendgo-- Code EndsKishore.P |
 |
|
b.veenings
Yak Posting Veteran
96 Posts |
Posted - 2007-07-06 : 08:55:59
|
try this one:select * from sysfilegroups cross join sysobjectsNeed an SQLDB consultant?check www.veeningsengineering.nl |
 |
|
Madhav
Starting Member
38 Posts |
Posted - 2007-07-06 : 09:02:30
|
guys...i got this query.select so.name,s.groupname, f.filenamefrom sysfilegroups s, sysindexes i, sysobjects so, sysfiles fwhere i.id = so.idand s.groupid = f.groupidand i.indid < 2and i.groupid = s.groupidand xtype = 'u'i think its working finethanks guysfor ur effort.quote: Originally posted by kishore_pen Hi Madhav,Can you try the following way:-- Code Startsdeclare @ObjId int, @RCnt int, @Cnt int, @FGName varchar (128)-- Creating temp. tabledeclare @Result table( ObjID int, ObjName sysname, Type char (2), FGName varchar (128))begin insert into @Result (ObjID, ObjName, Type) select Id, Name, XType from dbo.Sysobjects with (nolock) where xtype in ('U', 'V') -- user tables & views select @Cnt = 1 , @RCnt = 0 select @RCnt = count (*) from @Result while (@Cnt <= @RCnt) begin set rowcount @Cnt select @ObjId = ObjID from @Result order by objID set rowcount 0 select @FGName = s.groupname from sysfilegroups s with (nolock), sysindexes i with (nolock) where i.ID = @ObjID and i.indid < 2 and i.groupid = s.groupid update r set FGName = @FGName from @Result r where ObjID = @ObjId set @Cnt = @Cnt + 1 end select * from @Resultendgo-- Code EndsKishore.P
|
 |
|
|
|
|
|
|