How to update multiple records in a column with value "NULL"?

Eric Bourland
Eric Bourland used Ask the Experts™
on
ColdFusion 9
MS SQL Server 2005

* I have a table, tbl_Document_Has_Topic, with 923 records.

* That table has column DocumentTopicID.

* In 422 records, column DocumentTopicID has value: 3

In column DocumentTopicID I want to replace all values "3" with values "NULL". I don't want to edit each record. Is there an UPDATE command that I can use, to update this table column?

Does this look right to you?

UPDATE tbl_Document_Has_Topic
SET DocumentTopicID = "NULL"
WHERE     (DocumentTopicID = 3)

This table is in production; I am trying to undo the client's repetitive work to populate column DocumentTopicID with value = 3. I wanted to run this by some experts before I proceed. I have made a backup of the table. I am using SQL Server Studio Manager 2005 to edit the database.

Thanks as always.

Eric B
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Commented:
I don't know why you need to do this, but the syntax is almost right. Just remove the quotes around "NULL"

ie
UPDATE tbl_Document_Has_Topic
SET       DocumentTopicID = NULL
WHERE  DocumentTopicID = 3

Author

Commented:
Worked just as it should. Thank you _agx_!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial