INSERT

  • tblemp (empid,jobid,position)

    Here the acceptable values for field position is (4,6,7)

    I wud like to check if the field position has (4,6,7) if it doesnt then insert the wrong entry in a #temp table and display it in the result set.

    is it possible with CASE statements?

  • Why not

    select * into #temp from mytable where postion not in (4,6,7)


  • If you are using a frontend app you could probably take care of that kind of validation on the frontend. If the values entered meet the validation criteria then do insert into table. If they do not meet validation criteria throw a message up.

    Greg

    Greg
    _________________________________________________________________________________________________
    The glass is at one half capacity: nothing more, nothing less.

  • I do have 2 tables where i need to find for errors and display a resut set. From the 2 tables there are fields more than 20 which may have errors, how can i populate all the errors in a single table and display them

  • select * into #temp from mytable where

    (postion not in (4,6,7))

    or

    (datefield not between mindate and maxdate)

    or

    somefield <> [what it should equal]

    and you could do the same for table2

    You would need to store the errors in seperate tables unless the 2 tables have the same ddl or you could just store the unique id for each of records in the error table


  • I just want to insert id field and the error field into the temp table, want to join 2 tables which has error and the 2 tables will be having multple fields with errors.

Viewing 6 posts - 1 through 5 (of 5 total)

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