hi,
Here is a query i have written to find the tables not used by any store procedures..
......................................................................................
Declare @tablename nvarchar(40)
Declare tablecursor cursor for
Select name from sysobjects where xtype = 'U'
DECLARE @sqlCommand nvarchar(1000)
declare @rowCount int
DECLARE @searchstring varchar(50)
DECLARE @ParmDefinition nvarchar(500);
create table #temp
(
UnusedTables nvarchar(40)
)
open tablecursor
fetch next from tablecursor into @tablename
while @@fetch_status = 0
begin
set @searchstring='p'
SET @sqlCommand = N'SELECT @rows = count(o.name) from sysobjects o ,
syscomments c where o.type='+char(39)+@searchstring + char(39)+' and
o.id=c.id and c.text like '+ char(39)+'%' + @tablename +'%'+char(39);
SET @ParmDefinition = N'@rows int OUTPUT';
EXECUTE sp_executesql @sqlCommand, @ParmDefinition,@rows=@rowCount OUTPUT;
if @rowCount = 0
begin
insert into #temp values (@tablename)
end
fetch next from tablecursor into @tablename
end
close tablecursor
deallocate tablecursor
select UnusedTables from #temp
drop table #temp
thanks
SA