I'm using ms sql 2008 and trying to create a database name that references another database. For example 'Dev', 'Test', 'Demo' would be database names that i could reference from my multiple config files, but each name would point to another database such as 'db20080101' or 'db20080114'.
[Edit]Some of the configs are for applications that i control the code and some aren't (ex. MS Reporting service datasource file configs)[/Edit]
It seems that sqlserver only supports synonyms for View,Table,Sproc, or Function. And Alias' are for table and column names.
Is there a way to do this that i missed in the docs? Any one have any suggestions on a workaround?
Go to the Database you wish to create Alias, Create an Alias Folders table with the preferred design, Go to unique IDs's table and check the last code sequence for the table created. For example, if the last code is 10, then update it to 11.
Each database can have only one DB alias. Each DB alias name must be unique.
Use SQL Server Management Studio In Object Explorer, expand the database where you want to create your new view. Right-click the Synonyms folder, then select New Synonym.... In the Add Synonym dialog box, enter the following information. Type the new name you will use for this object.
SQL Server CREATE SYNONYM statement syntax First, specify the target object that you want to assign a synonym in the FOR clause. Second, provide the name of the synonym after the CREATE SYNONYM keywords.
use 3 part notation and alias up to the table, example
select * from tempdb.dbo.sysobjects a join master.dbo.sysobjects b on a.id = b.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With