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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
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.
Tim HumphriesDirectorCommented:
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
Rob099Author Commented:
Can I also add another instruction to the query to apply that clear column only from rows 25 to 75.  
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Om PrakashCommented:
-- 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.
Tim HumphriesDirectorCommented:
It depends on how your table is ordered in the list. If you do not have sequential numbers beginning at 1 (without any gaps) then the above will not work.

So, first determine what field you want to order the results by. Then you can use the row_number() function to identify the rows to be deleted.

    select *, row_number() over (order by <your field>) as rownum
	from <your table>
SELECT * -- better select first to check, before you delete!
FROM tab 
WHERE rownum BETWEEN 25 and 75

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tim HumphriesDirectorCommented:
I meant updated, not deleted, of course...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.