Hi, I'm pretty new to actually doing something useful in SQL, so can someone shed some light on my problem. I need to change from my current database to the master database, execute some sp_addextendedproc statements, then return to the previous database. Thats it. I don't know the name of the current database, so a simple:
wouldn't work. I've tried declaring a varchar and stuffing the name of the current database in there prior to exectuing the statement, but the USE statement refuses to accept the (seemingly valid) database name contained within my variable when I try to return:
Any help greatly appericated.
Many thanks
Yum.
Code:
USE master
sp_addextendedproc #1
sp_addextendedproc #n
USE currentdatabase
Code:
DECLARE @blah varchar(100)
SET @blah = DBNAME(DB_ID())
USE master
SELECT @blah AS "the current dbs name"
USE @blah
Many thanks
Yum.