Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to clear the contents of a single column

Author  Topic 

MagicCity77
Starting Member

19 Posts

Posted - 2008-09-30 : 10:14:29
Helo all,

I would like to know how do you clear the content of a single column.

Here is the script that I thought I could use to implement this.

ALTER TABLE tb_Main ALTER COLUMN Ext set NULL


I want to be able to go back and clear out the Extension for the Ext column.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-09-30 : 10:20:03
update tb_main set Ext = NULL

Be One with the Optimizer
TG
Go to Top of Page

CodesMyBusiness
Starting Member

9 Posts

Posted - 2008-09-30 : 10:21:11
If you want to 'clear' the value of a column, all you need to do is SET the value.

Example:
UPDATE tb_Main WITH (ROWLOCK)
 SET Ext = NULL
Go to Top of Page

MagicCity77
Starting Member

19 Posts

Posted - 2008-09-30 : 10:47:27
Wow, that's it????

Thanks

I have so much more to learn.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-30 : 10:55:33
The suggested methods clear complete column for all records.
If you only want to clear the column for some records, use a WHERE clause.
UPDATE Table1
SET Col1 = NULL
WHERE Col2 = 'USA'



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -