如何创建Sql同义词或“别名”;数据库名称? [英] How to create Sql Synonym or "Alias" for Database Name?
问题描述
我正在使用ms sql 2008,并尝试创建引用另一个数据库的数据库名称。例如, Dev, Test, Demo是我可以从多个配置文件中引用的数据库名称,但是每个名称都指向另一个数据库,例如 db20080101或 db20080114。
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'.
某些配置用于我控制代码的应用程序,而某些则不是(例如MS Reporting Service数据源文件配置)[/ 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]
似乎sqlserver仅支持View,Table,Sproc或Function的同义词。别名用于表和列的名称。
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?
推荐答案
在表中最多使用3部分表示法和别名,例如
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
这篇关于如何创建Sql同义词或“别名”;数据库名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!