I have two databases DB_External and DB_Internal.
I am writing some stored procedures (in DB_Internal) that reads from
the tables in DB_External. I execute my stored procedures from
DB_Internal.
Everytime I want to read the tables in DB_External, I have to refer to
the table as DB_External.dbo.tableName.
Is there a better way of declaring the database DB_External up front
in the stored procedure so I don't have to pre-fix "DB_External.dbo."
in all the table names?
Thanks in advance,
June Moore."June Moore" <jungewum@.yahoo.com.au> wrote in message
news:e5dfaf21.0310100030.3e0067a5@.posting.google.c om...
> Hi all,
> I have two databases DB_External and DB_Internal.
> I am writing some stored procedures (in DB_Internal) that reads from
> the tables in DB_External. I execute my stored procedures from
> DB_Internal.
> Everytime I want to read the tables in DB_External, I have to refer to
> the table as DB_External.dbo.tableName.
> Is there a better way of declaring the database DB_External up front
> in the stored procedure so I don't have to pre-fix "DB_External.dbo."
> in all the table names?
> Thanks in advance,
> June Moore.
You always have to fully qualify the name - there's no way around that. And
it's good practice to include the dbo owner prefix, even in the 'local'
database.
If you're concerned about moving code between servers where the DB names may
be different, you could consider a pre-processor script to 'fill in' or
find/replace the DB names in a code template, then create the procedure.
Simonsql
No comments:
Post a Comment