if exsist(select X From Table where expression)
  pringt ""
else
  print ""

解决方案 »

  1.   

    if exists (select top 1 * from Table where ...)
       print 'dfadf'
    else
      print 'gdsgds'
      

  2.   

    if (select count(0) from table where ...) > 0
      print 'y'
    else
      print 'n'-- or
    if exists(select 1 from table where .....)
        print 'y'
    else 
        print 'n'
      

  3.   

    declare @icount int
    select @icount=count(*)from table
    if @icount>0
    begin
    print 'y'
    end
    else
    begin
     print 'n'
    end
      

  4.   

    if (select b.rows
    from sysobjects a,sysindexes b where a.id=b.id and a.name='表名') is not null  print 'y'
    else
      print 'n'
      

  5.   

    if exists(select 1 from table where .....)
        print 'y'
    else 
        print 'n'