Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want delete only perticular column values from without affecting any other column in the database . How can I achive this?
Posted
Comments
Bh@gyesh 21-Apr-14 5:22am    
Do u mean to say delete column of delete a row based on some column value?

Like this:

SQL
ALTER TABLE table_name
DROP COLUMN column_name


http://www.w3schools.com/sql/sql_alter.asp[^]

Btw, is Google [^]broken at your place?
 
Share this answer
 
Manas BHardwaj solution will work, but it deletes the column from the database as well as the values it contains. So if any of your other software uses that column, it will fail when it tries to access it.

It may be that you want to get rid of the values in the column only: that's also pretty simple.
Assuming the column is NVARCHAR:
SQL
UPDATE myTable SET MyColumn=''
Will remove all the values.
If the column is NULLABLE, then:
SQL
UPDATE myTable SET MyColumn=NULL
Is a better solution.
 
Share this answer
 
Comments
Ni!E$H_WAGH 21-Apr-14 6:06am    
Thanks OriginalGriff
OriginalGriff 21-Apr-14 6:23am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900