开发者

Delete the column for the particular value

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 = '0开发者_Go百科01'

The above query is not working.

How to make a delete query for delete the particular column

Need Query Help


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:

  • Altering a column to be nullable


I think you want to set the value to null

update Table1 set value=NULL where id='001'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜