1
from
[PMDB].[dbo].PROJECT P
inner join PROJWBS PW on P.proj_id = PW.proj_id
and PW.proj_node_flag = 'Y' and PW.wbs_short_name not like '%- B%'
and PW.status_code <> 'WS_Planned' and PW.status_code <> 'WS_Whatif'
inner join [PMDB].[dbo].TASKSUM TS on PW.proj_id = TS.proj_id and PW.wbs_id = TS.wbs_id
inner join reference..fiscal_year_qtr_month FYQM on isnull(TS.act_end_date,P.scd_end_date) > FYQM.fiscal_month_begin_datetime
and isnull(TS.act_end_date,P.scd_end_date) <= FYQM.fiscal_month_end_datetime
inner join reference..mfg_year_month_ww MYMW on isnull(TS.act_end_date,P.scd_end_date) > MYMW.mfg_ww_begin_datetime
a

我已经尝试过互联网,但只是不明白“参考..”在这里是什么意思。我错过了什么吗?

4

3 回答 3

6

reference是数据库名称。在数据库名称和对象名称之间是架构。

因此,如果您想从sys.database_filesin查询master,您会说:

SELECT name FROM master.sys.database_files;
---- database ---^^^^^^
------------- schema ---^^^
----------------- object ---^^^^^^^^^^^^^^

如果您知道实体名称是明确的,则可以省略架构。对于目录视图/DMV,您不能忽略它,但如果您使用默认模式(通常是 dbo),则可以忽略显式引用。这不是一个好主意

于 2013-04-22T19:00:37.587 回答
4
reference..mfg_year_month_ww

是简写

reference.dbo.mfg_year_month_ww

基本上这意味着使用默认模式。

于 2013-04-22T19:02:10.873 回答
-1

这是指示表名称和所有者的 T-SQL(Microsoft 特定)语法。默认所有者是“dbo”。默认数据库是您当前“使用”的任何一个。

以下是更多详细信息:

http://examplesql.com/sqlserver-t-sql-tsql/dbo-dotdot-syntax/

SELECT * FROM AdventureWorks2008.dbo.AWBuildVersion;

说实话,这不是火箭科学。当在 tsql 查询中引用默认模式时,'..' 可以用作 dbo 的替代品。如果您需要频繁访问默认数据库,dbo .. 语法快捷方式可以大大提高您的效率。

于 2013-04-22T19:00:59.103 回答