Synonyms 1

  • Comments posted to this topic are about the item Synonyms 1

  • In the question:

    CREATE SYNONYM Emp

    but in the explanation:

    SELECT * FROM emp2

    From where this emp2 came?!

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • But anyway it`s good question although I am using table aliases in the code structure more than synonyms.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • Interesting question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • ...but it works for Joe in HR (that's his default schema);-)

    😎

  • Hany Helmy (9/7/2014)


    In the question:

    CREATE SYNONYM Emp

    but in the explanation:

    SELECT * FROM emp2

    From where this emp2 came?!

    a typo. It's fixed

  • good question.

    Vimal LohaniSQL DBA | MCP (70-461,70-462)==============================The greatest barrier to success is the fear of failure ** Success is a journey not a destination**Think before you print, SAVE TREES, Protect Mother Nature

  • Steve Jones - SSC Editor (9/7/2014)


    Hany Helmy (9/7/2014)


    In the question:

    CREATE SYNONYM Emp

    but in the explanation:

    SELECT * FROM emp2

    From where this emp2 came?!

    a typo. It's fixed

    Thx.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

  • in sql server 2012 I am able to create the synoname also I am able to select the rows from the table.

    so this means this is only true in the older version of the sql server.

    Thanks

    Vineet

  • Never gave it a second thought but figured deferred name resolution should be in play during synonym creation. Thanks for the question.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Eirikur Eiriksson (9/7/2014)


    ...but it works for Joe in HR (that's his default schema);-)

    😎

    That's true!

  • interesting question. Thanks for share

  • vineet_dubey1975 (9/8/2014)


    in sql server 2012 I am able to create the synoname also I am able to select the rows from the table.

    so this means this is only true in the older version of the sql server.

    Thanks

    Vineet

    USE LOCALWORK

    GO

    CREATE SCHEMA HumanResource

    GO

    CREATE TABLE HumanResource.Employee

    (

    EmpID INT IDENTITY,

    EmpName Varchar(10)

    );

    GO

    CREATE SYNONYM Emp FOR Employee;

    SELECT * FROM EMP;

    Just to confirm, if the above way you tested, then no, it still gives you the error below error in Sql 2012 dev edition (which currently I am using)

    Msg 5313, Level 16, State 1, Line 1

    Synonym 'emp' refers to an invalid object.

    -//edit- Post your code, may be it is something different or I must have understood it wrong.

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Thank you, SJ, interesting one.

    (I had selected 2nd choice, but still I wrote the code to test my analysis... I succeed :-). To be honest, never tried this explicitly.)

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • This was removed by the editor as SPAM

Viewing 15 posts - 1 through 15 (of 36 total)

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