insert value

  • If a record returns null for a particular field I would like to insert -1 into that row.  How is this done?

     

    Select * from aTable where aField = 'aValue'

    afield may have aValue in every row but bField will have null in many rows.  I would like to insert -1 into those rows.

     

     

    Thank you for any assistance

  • update aTable set bField=-1 where aField='aValue' and bField is NULL

  • After You have completed this task you will want to set the column to NOT NULL, and perhaps DEFAULT = -1.

    ALTER TABLE myTable ALTER COLUMN myColumn INT NOT NULL

    ALTER TABLE myTable ADD CONSTRAINT DF_myColumn_MinusOne DEFAULT(-1) FOR myColumn

    Or just in EM.

    /rockmoose


    You must unlearn what You have learnt

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

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