公司明天下午就要交程序了,需要用到SQL Procedure预存函数,本人是自学的,一直没有学过Procedure,求高手帮我写出以下类似的程序就行了,跪求了,各位大哥~~~表A有数据段a,b,c,e..
表B有数据段a,b,d,..(这里少c)要做的效果:写出所有A中的内容,用Procedure判断在B中是否有数据,如果有,则跳过, 如果没有,请把A中这个没有数据写出来,(也就是以上表A中的c,e)。我知道CSDN高手很多,耽误您一点时间帮我解决了吧。~~~再次感谢了~~

解决方案 »

  1.   

     谢谢 duanzhi1984 帮忙,应该说要查询表A 不在表B中的数据。  也就是 A not in B 的数据,能用Proceduce做到吗?
      

  2.   

    select * from a where id not in (select id from b)select * from a where not exists(select * from b where id=b.id)
    想要准确结果,请给出测试记录,结果
      

  3.   

    Create table #1([id] int,[content] nvarchar(3),[NO] nvarchar(8))
    Insert #1
    select 1,N'abc',N'001' union all
    select 2,N'abc',N'0005' union all
    select 3,N'abc',N'011' union all
    select 8,N'abc',N'0015' union all
    select 9,N'abc',N'i2101' union all
    select 10,N'abc',N'00c0409' union all
    select 11,N'abc',N'000i7809' union all
    select 12,N'abc',N'c031'declare @n nvarchar(20)
    set @n='0c0409'
    select * from #1 where [no] like '0%'+@n+'%'
      

  4.   

    insert into tablename(fldname...)
    select fldname... from a where not exists(select * from b where b.fldname=a.fldname)