--测试数据
create table ta(b int, c int, id int)
create table tb(d int, e int, id int)
insert ta  select 1, 22, 3
union  all select 2,  2, 4
insert tb  select 2,  3, 3
go
--创建存储过程
/*我觉得没有必要写成存储过程,一条语句就可以了。
或者你把它定义成视图也行*/
create proc proc_temp
as
select ta.*, d=isnull(d, 0), e=isnull(e,0)
from ta left join tb
on  ta.id=tb.id
go
exec proc_temp
--清除
drop proc proc_temp
drop table ta
drop table tb

解决方案 »

  1.   


    declare @a table(b int,c int,id int)
    insert @a values(1,22,3)
    insert @a values(2,2,4)
    --select * from @adeclare @b table(d int,e int,id int)
    insert @b values(2,3,3)--select * from @bselect a.*,isnull(b.d,0) as d,isnull(b.e,0) as e from @a a left join @b b on a.id=b.id
      

  2.   

    楼上的说的很对,不用存储过程.
    它的关键是使用了.left join  楼主,你看看帮助就会明白了.
      

  3.   

    select a.*,b.d,b.e from a left join b on a.id=b.id
      

  4.   


    select ta.*,tb.d,tb.e from ta left join tb on ta.id = tb.id
      

  5.   

    select a.*,b.d,b.e from a left join b on a.id=b.id
      

  6.   

    select a.*,isnull(b.d,0),isnull(b.e,0) from a left join b on a.id=b.id
      

  7.   

    请问filebat(),你的存储程序怎么删除.
    我还不会删除存储呢??谢谢指点.
      

  8.   

    --删除存储过程
    drop proc proc_temp