【T-SQL】基础——表别名
Som有时候我们需要为表设置别名,这样就可以方便的修改表。
如果在SSMS中,可以点击 Query-> SQL CMD mode
--Set Alisa for the table
:setvar tablename "[RetailDataWarehouse].[dbo].[FactUnit]"
Select ExternalOrderId,COUNT(DISTINCT(RetailTransactionId)) AS IDCount
into #X
--Use as a variable
From $(tablename)
group by ExternalOrderId