Link to home
Start Free TrialLog in
Avatar of Rob099
Rob099Flag for United States of America

asked on

SQL server managment studio, how to clear data from one column only

SQL server managment studio, how to clear data from one column only. I manage my database tables on my server with SQL server managment studio. I need to clear the data from a column without deleting that column. I'm a novice  with databases and this SQL server managment studio.
Avatar of Om Prakash
Om Prakash
Flag of India image

You cannot delete column data from SQL management studio, but you can write simple SQL query to do so:

UPDATE your_table SET your_field = ''
This will set all the data in your_field as blank.
Above will work if the column is text, but it would be better to ensure that the field allows nulls (set this in management studio) and then set the column to null:

UPDATE your_table SET your_field = null
Avatar of Rob099

ASKER

Can I also add another instruction to the query to apply that clear column only from rows 25 to 75.  
-- Add where condition
UPDATE your_table SET your_field = ''  WHERE your_field_id between 25 and 75
--Assuming your_field_id is the primary key column as integer and contains sequential numbers.
ASKER CERTIFIED SOLUTION
Avatar of Tim Humphries
Tim Humphries
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I meant updated, not deleted, of course...