Query

  • I have a result set with 2 char where in all records are either ST,SV,SU......

    when using an IF condition how can I find the odd one from that result set. Odd one in the sense there shud be no other record other than ST,SU,SV, If so I have to kick an error mesg.

  • Select Id, Col2, YourCol from dbo.YourTable where YourCol NOT IN ('ST', 'SV', 'SU') order by ??

     

  • If you are just interested in raising an error if one of the other "types" exists then you can use the following

    if exists (select top 1 1 from dbo.YourTable where YourCol NOT IN ('ST', 'SV', 'SU') )

    begin

     raiserror ....

     any other error handling

     return

    end

     

     


    I feel the need - the need for speed

    CK Bhatia

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply