Use master
go
create proc sp_TableCount as
select count(*) TableCount from sys.tables
where type_desc='USER_TABLE'
GO
use master
exec sp_TableCount
use test
exec sp_TableCount
you always get the TableCount from the Master database.
how can I switch to current database in SP procedure ?
use db_name() ??
--SQL 2005
hello