SQL Server Performance

Can a synonym be used for the first two parts of the naming scheme, server.databasename

Discussion in 'SQL Server 2008 General Developer Questions' started by WingSzeto, Jun 11, 2009.

  1. WingSzeto Member

    I like to create a synonym to represent the first two parts of the four part naming scheme. Based on BOL, a synonym can be used for base objects like table, view, sp, etc. but not for server name and database name. If a synonym can't be used for servername.databasename, what other way can I use?
    We want it that way because if we move our code among servers under different db name, we only need to change the synonym once without affecting the code.
  2. ndinakar Member

    Typically, people use 2 part - <schemaname>.<objectname> rather than 4 part. The server name and database name is usually in the connection string which is put into the web.config file (at least back in 2003 when I wrote .NET code). When you move your app between servers, you just need to change the value in the web.config file to the appropriate server name. Your app will just get the connection information from this xml file.
  3. WingSzeto Member

    Let's say this is required straightly in SQL envirnoment...... there is no web application involvved... Is there still a way?

Share This Page