如何将以下数据横向显示

现有两张表,分别为 A_table,B_table
分别存储数据如下:
A_table

id name
1 zhang
2 li
3 wang

B_table

id type value
1 a 1
1 b 2
2 c 2
3 b 1
3 d 3

现在问题是 如何能实现如下显示
id name a b c d
1 zhang 1 2
2 li 2
3 wang 1 3

希望大家给点建议,谢谢!

Create PROCEDURE proc_name
AS
declare @i int,
@count int

set @count=(select count(*) from A)
set @i=0
while(@i<@count)
begin
@i=@i+1
select id,name, top1 from (select * top i from A ) order by id desc
end
go

这样够详细了呗..
exec proc_name 就可以了

http://book.51cto.com/art/200812/99990.htm 参考这个

汗.. 下存储过程循环查询每条信息
每次查一次 类似

for 中 i++ i< (select count(*) from A)
每次
select id,name, top1 from (select * top i from A ) order by id desc
这样就可以了 都是横向的 哈哈
自己去修修补补下..
这个够形象体贴了吧。。。