• Not with a loopback.

    using a linked server/loopback is going to require four part naming conventions. leaving out the database name would default to the default database of the user connecting, probably the master database. there's no way for the linked server to infer database context.

    without the linked server, then yes, you can put a stored procedure in master, make sure it starts with "sp_" , ie [sp_ErrorLogging], and mark it as a system object via EXECUTE sp_ms_marksystemobject 'sp_ErrorLogging'

    then , if you were in whatever database, you can call it, and it would infer the database reference of the current context.

    ie if i was in [production],, and referenced sys.tables, the procedure would get data from [production].sys.tables; jump to tempdb, and the same procedure now looks at [tempdb].sys.tables.

    without the sp_ms_marksystemobject , it would reference master.sys.tables, but could be called form any database context.

    if the procedure assumes a specific table, ie dbo.LoggingTable exists, as long as that table is in the current db schema, it will reference the current db context.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!