2

Using Sql Server 2005

Table1

ID Name Value

001 Rajesh 90
002 Suresh 100
003 Mahesh 200
004 Virat 400
...

I want to delete the value from the table1 for the particular id

Tried Query

Delete value from table1 where id = '001'

The above query is not working.

How to make a delete query for delete the particular column

Need Query Help

Gopal
  • 11,712
  • 52
  • 154
  • 229

2 Answers2

8

There are at least two errors with your statement:

  • The word table will give a syntax error because it is a reserved word. You need to specify the table name of the specific table you wish to delete from.
  • Also you cannot write DELETE value FROM. It's just DELETE FROM. And note that it deletes the entire row, not just a single value.

A correct delete statement would look like this:

DELETE FROM table1
WHERE id = '001'

However if you want to change a single value to NULL you should use an UPDATE statement.

UPDATE table1
SET value = NULL
WHERE id = '001'

Of course this assumes that the column is nullable. If not, you'll have to fix that first. See this question for details:

Community
  • 1
  • 1
Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
5

I think you want to set the value to null

update Table1 set value=NULL where id='001'
TigrisC
  • 1,320
  • 9
  • 11