
SELECT Convert(varchar(128),'Person.Address') as ItemName, count(*) as Rows INTO #Map_Temp_Table from Person.Address INSERT INTO #Map_Temp_Table SELECT 'Person.Contact', count(*) as Rows from Person.Contact INSERT INTO #Map_Temp_Table SELECT 'Production.Culture', count(*) as Rows from Production.Culture INSERT INTO #Map_Temp_Table SELECT 'Sales.Customer', count(*) as Rows from Sales.Customer select * from #Map_Temp_Table drop table #Map_Temp_Table
对于我们的输入列表的第一个元素,SP_map使用了CREATE模板动态地定义了一个临时表,并存储第一个结果集。对于后面的部分使用了UPDATE模板来向临时表追加行。当完成时,使用一条SELECT语句从临时表中查出所有的数据。并生成一个单独的结果集,最后删除临时表。
| 第1页: 映射概述 | 第2页: 在SQL中的基本映射 |
| 第3页: 在SQL中的聚合映射 |