Query

  • SET @per=(select top 1 substring(Col001,194,2)from Empwhere substring(Col001,1,6) = 'HEAD')

    If Exists(select substring(Col001,1,2)from Emp where substring(Col001,17,2)='DH'not in (@per))

    Begin

    RAISERROR ('Mesg')

    return

    end

     

    I am getting the error at not.

  • Your missing something

    If Exists(select substring(Col001,1,2)from Emp where substring(Col001,17,2)='DH' And substring(Col001,17,2)='DH' not in (@per))

    But is easier to read if

    If Exists(select * from Emp where substring(Col001,17,2)='DH' And substring(Col001,17,2)='DH' <> @per)

  • still am getting the same error.

  • I doubt if I can have multiple where clause in a single select statement

  • Tell me what u wanted to do. There is syntax error.

    substring(Col001,17,2)='DH'not in (@per) is incorrect. what are u trying to do.

    Thanks

    Sreejith

  • I want to check

    1) select substring(Col001,1,2)from Emp where substring(Col001,17,2)='HE'

    2) select substring(Col001,1,2)from Emp where substring(Col001,17,2)='DH' not in (select substring(Col001,1,2)from Emp where substring(Col001,17,2)='HE')

     

    all the records in 2 shud match with 1 other wise kick an error.

  • What?

    Of course you can have multiple items in the where clause, Unfortunatelly I wasn't paying attention when I posted

    Try this.

    If Exists(select substring(Col001,1,2)from Emp where substring(Col001,17,2)='DH' And substring(Col001,17,2) not in (@per))

     

  • syntax is working but unable to filter the records from not in

  • I want ur question in Plain English (No Not IN...)

    what column are u checking in NOT IN Clause?

     

  • Fine,

    Can you post a table definition, some sample data, and what you want as an expected result.

     

    Thx

  • I am checking @per in my NOT IN caluse, uou can check my 1st  posted mesg.

Viewing 11 posts - 1 through 10 (of 10 total)

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