July 1, 2004 at 12:47 pm
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
July 1, 2004 at 1:01 pm
update aTable set bField=-1 where aField='aValue' and bField is NULL
July 2, 2004 at 3:57 am
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