GabrielVa
GabrielVa

Reputation: 2388

SQL UPDATE Command

Question. I'm trying to use SQL to update a listview in C#. Using the Query Builder I can do a select, update, insert and delete. Ive got my select but I'm trying to get my update to work with no luck.( I want to use the update button on the listview to update the record) I need some insight as I think I'm writing it wrong. Thanks

 UPDATE       SF1411
 SET  ( ItemNumber, QuoteNumber, Item, Descp, Route, Unit, QTYOH, EXTQTY, CSTCD, 
      PCOST, SCOST, ACOST, TCOST, ICOST, Date, BIZCODE, DeleteItem)   
  =  SELECT [ItemNumber], [QuoteNumber], [Item], [Descp], [Route], [Unit], [QTYOH], 
     [EXTQTY], [CSTCD], [PCOST], [SCOST], [ACSOT], [TCOST], [ICOST], [Date], [BIZCODE],   
    [DeleteItem] 
    FROM [SF1411] WHERE ([QuoteNumber] = @QuoteNumber)

Upvotes: 2

Views: 1371

Answers (3)

Vanshika
Vanshika

Reputation: 1

Just set individual values like below:

UPDATE SF1411
SET ItemNumber = SELECT [ItemNumber] FROM [SF1411] WHERE ([QuoteNumber] = @QuoteNumber);

Mostly this is used to update a specific value or if using select in set then it used to select from different table like:

Update table set column= "value" where condition;

or:

Update table set column = select column from tbl where condition;

Upvotes: 0

Nakul Chaudhary
Nakul Chaudhary

Reputation: 26164

If I am correct your update command is wrong.

you need to tell value of each column rather than just fire a select command.

Upvotes: 0

Danish Khan
Danish Khan

Reputation: 1891

Im sorry if I understand you wrong, but shouldn't an update statement look like this..

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value

Upvotes: 2

Related Questions