Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
abarringer
Starting Member
13 Posts |
Posted - 2005-08-23 : 15:51:41
|
| I'm trying to create a procedure in the master database that will be used from user database(s).It seems that it's not resolving the references to user created tables to the current database, although all other functions seem to reference the current database. Example:table tbltest exists in database mydb.Create procedure in master database named sp_mymasterproc and execute from mydbsuch asUse MasterGOCREATE PROCEDURE sp_mymasterproc/*This returns current database context,as anticipated.*/select db_name() / *this returns the objects of the current database context, as you would expect.*/select * from sysobjects /* this returns all rows from tbltest incurrent database context, as you would expect*/exec('select * from tbltest')/*This fails with object not found...*/select * from tbltestGOuse MydbGOcreate table tbltest(test varchar(10))GOexec sp_mymasterprocGO |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-24 : 01:09:21
|
| you should use DBname..objectName to access the objects from other databasesMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|