Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

switch to current database in SP procedure

$
0
0
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

Viewing all articles
Browse latest Browse all 23857

Trending Articles