Hello Everybody,
I have been trying to find out total count of rows in each tables which are de-activated. In my DB I have 20 tables with column IsActive.
I have tried below cursor,however it is getting error saying Invalid object name @Namee.
Create table #t
(
NoOfRows bigint,
)
Declare @Namee Varchar(500)
Declare @GetName Cursor
Set @Getname = Cursor for
Select table_name from information_Schema.columns
where column_name='isactive'Open @Getname
Fetch Next From @Getname into @Namee
While @@Fetch_Status=0
Begin
insert into #t Select count(*) from @Namee where isactive=0
Fetch Next From @Getname into @Namee
End
Close @GetName
Deallocate @GetName
select * from #t