Simple Synonym question

  • Can I make a Synonym for an entire Database ?

     

    For example something like....

    create

    SYNONYM syndDB FOR [YourServerName].YourDatabaseName]

    and then

    select * from [syndDB].sys.sysobjects

     

    TIA

     


    Mathew J Kulangara
    sqladventures.blogspot.com

  • Synonyms are only for the schema objects.

  • The attempt to create a synonym for a DB appears to execute successfully, but then to reference that in a select fails.  Synonym works well with tables where the fully qualified name is onerous but you can't reference the synonym for a DB even though it appears to get created.

    Create

    synonym ab for doomeddb.dbo.accbalance

    select

    * from ab

    1   2006 1000.00

    1   2007 2000.00

    1   2008 3000.00

    2   2006 4000.00

    2   2007 5000.00

    3   2008 6000.00

    create

    synonym dm for doomeddb

    Command(s) completed successfully

    select * from dm.dbo.accbalance

    Msg 208, Level 16, State 1, Line 1

    Invalid object name 'dm.dbo.accbalance'.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply