views:

27

answers:

5
+1  Q: 

SQL 2000 Set Query

Hi,

I have a SQL 2000 server with a database (ITinventory) and a table which is also called ITinventory. I would like to create a query which will look at the field 'Status', if the status is 'disposed' then I would like to set a 'location' field to 'disposed'.

Many thanks

A: 
UPDATE ITInventory SET Location = 'disposed' WHERE Status = 'disposed'

This SQL is making various assumptions otherwise not clarified in the OP...

Adam
A: 
update ITinventory
set location='disposed'
where status ='disposed'
Madhivanan
+1  A: 
UPDATE ITinventory
SET location = 'disposed'
WHERE status = 'disposed'
Krunal
A: 

Try this.

UPDATE ITInventory SET Location = 'disposed' 
WHERE Status = 'disposed' AND Location != 'disposed'

Greets Flo

Florian Reischl
+1  A: 
update 
    ITinventory 
set 
    Location = Status 
where 
    Status = 'Disposed'
CodeBadger
Over engineered, without any need to do so. Who told you Location and Status are related at all ?
this. __curious_geek
I disagree, the poster has indicated he's setting the Location column value to the same as the Status column, where the Status column has a specific value. This query reduces the amount of free text in the query, while forcing the person running it to recognise the logic that it's performing - potentially making you think about how valid the update is a little better. That said, it's just a quick update statement, I doubt it really matters!
CodeBadger