sql server 多张雷同结构的数据表查询

sql server 多张相同结构的数据表查询
表NameInfo
id          Name   tbName
001        M1         tb1
002        M2         tb2
003        M3         tb3
表tb1 对应的名称是M1
id        value
1           2
2           3
3           4
4           5
5           6

表tb2对应的名称是M2
id        value
1           4
2           3
4           4
5           9

表tb3对应的名称是M3
id        value
1           2
3           4
5          5
6           6
7          10
8           12

需要得到结果:
id     M1            M2       M 3 
1       2             4            2
2       3             3            NULL
3       4           NULL       4
4       5              4            NULL
5       6              9            5
6      NULL    NULL      6
7      NULL    NULL      10
8      NULL    NULL      12
------解决方案--------------------
你这个跟第一个表貌似没关系吧
----------------------------------------------------------------
-- Author  :DBA_HuangZJ(发粪涂墙)
-- Date    :2014-07-02 12:44:50
-- Version:
--      Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64) 
-- Jun 28 2012 08:36:30 
-- Copyright (c) Microsoft Corporation
-- Enterprise Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: ) (Hypervisor)
--
----------------------------------------------------------------
--> 测试数据[NameInfo]
if object_id('[NameInfo]') is not null drop table [NameInfo]
go 
create table [NameInfo]([id] nvarchar(6),[Name] nvarchar(4),[tbName] nvarchar(6))
insert [NameInfo]
select '001','M1','tb1' union all
select '002','M2','tb2' union all
select '003','M3','tb3'
--> 测试数据[M1]
if object_id('[M1]') is not null drop table [M1]
go 
create table [M1]([id] int,[value] int)
insert [M1]
select 1,2 union all
select 2,3 union all
select 3,4 union all
select 4,5 union all
select 5,6
--> 测试数据[M2]
if object_id('[M2]') is not null drop table [M2]
go 
create table [M2]([id] int,[value] int)
insert [M2]
select 1,4 union all
select 2,3 union all
select 4,4 union all
select 5,9
--> 测试数据[M3]
if object_id('[M3]') is not null drop table [M3]
go 
create table [M3]([id] int,[value] int)
insert [M3]
select 1,2 union all
select 3,4 union all
select 5,5 union all
select 6,6 union all
select 7,10 union all
select 8,12
--------------生成数据--------------------------

--select * from [M3]

--select * from [M2]

select COALESCE(M1.ID,M2.ID,M3.ID) ID,M1.value M1  ,M2.value M2,M3.value M3
from [M1] FULL JOIN [M2] ON M1.ID=M2.ID FULL JOIN [M3] ON M1.ID=M3.ID