Alias name to Database

  • Hi all,

    I have a Database with the name of 'Master'.

    Can i access the same database with different name from my front-end application?

    My Scenario is,

    My application1 is pointing (in connection string) DatabaseA (using Table1 and Table2).

    Another application application2 is pointing DatabaseB (using Table3 and Table4).

    ...

    Now I moved all the tables (Table1, Table2, Table3 and Table4) to new Database 'Master'. I Don't want to change my connection string in application1, applicable2 .... I want to continue the same connection string. Now i want to give the alias name to my new database 'Master' as DatabaseA and DatabaseB. So my application will start using the 'Master'.

    Can u please suggest me?

    Advance Thanks.

    Ramesh.p

  • Hi,

    you can use databsae synonyms for this.

    check the below example.

    The following T-SQL creates the synonym:

    CREATE SYNONYM [dbo].[DimProduct]

    FOR

    [AdventureWorksDW].[dbo].[DimProduct]

    If you now execute "SELECT * FROM DimProduct" in the AdventureWorks database, SQL Server returns data from the AdventureWorksDW.dboDimProduct table.

    For more details refer books online.

    Regards,

    Sriram

    Sriram

  • Hi Sri,

    Confusion is you are giving alias name to table or database?

    I need database.

    by

    Ramesh.P

  • Good Day,

    Using the name master for a database name is not the best idea, as this is the same as the system databases.

    If you created the tables inside the MASTER database (not a good idea) but you can do it.

    I know tables can have aliases, but i am not sure about databases.

  • As far as I know, there is no way to provide a database an alias name.

    By the way why would you want to do this?

    Just for the reason that your lazy to change the name in your connection string is a little too much to ask...dont you think!:hehe:

  • rameshnkl (2/10/2009)


    I have a Database with the name of 'Master'.

    :w00t: Shall we understand you manage to create a "master" database in your SQL Server environment or happens that you have created user tables inside your "master" database?

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • Sorry. Actually i mean, 'Master' is a example database name.

    No probs. Take my database name is 'Something'.

  • Problem is front-end not in my control. So i can't change the connection string.

    ok?

  • I also want to know the solution so I m including myself

    Thanks

  • Hello,

    Not sure if this works for you.

    My firm understanding We don't have an option to create a alias name for the database, you can create the alias for tables.

    But you can create a database snapshot and access the Database with the old same name.

    NOTE: Snapshot is only ment for reporting( i mean you can read the data and you cannot update)

    Let me know if this works for you.

    Syntax for creating snapshot

    Create database ON

    (Name='' FileName='')

    AS SNAPSHOT OF

    P.S: if you have too many updates to master database then snapshot growth will spike up.

  • Thank for reply.

    No. i want to do all operation(Insert, Update, Delete and Select)

  • rameshnkl (2/11/2009)


    Sorry. Actually i mean, 'Master' is a example database name.

    No probs. Take my database name is 'Something'.

    Got it. You may want to check this http://www.mssqltips.com/tip.asp?tip=1620

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • Thank Old hand.

    The link provided by you expalining alias to Server in SQL Server configuration.

    But my requirement is Alias to database name;

    by

    ramesh

  • I waiting for the answer still.

    Could pls anyone assist this issue?

    -Ramesh.P

  • ok.

    Setting the alias name to Database is possible or not?

    - Ramesh.P

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

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