Question:
Very basic SQL but I'm stuck?
Smiley Bomb
2011-11-02 12:54:11 UTC
My question says "Write an UPDATE statement that modified the InvoiceCopy Table. Chance the PaymentDate to today's date and the PaymentTotal to the balance due for each invoice with a balance due."

And my code is as given.


"UPDATE InvoiceCopy
SET PaymentDate = GETDATE()
WHERE PaymentTotal <> 0"

It's saying 103 rows affected, but it doesn't display any of them. Is it supposed to do that?
Six answers:
Gardner
2011-11-02 12:56:13 UTC
Yes that is correct.
TheMadProfessor
2011-11-02 20:10:02 UTC
That is correct. An action query (INSERT, UPDATE or DELETE) does not normally output anything to the user except possibly (depending on the DBMS) the number of rows affected (if any). If you wanted an echo back of the updated row, you could only do so either by means of a trigger (only recommended if you create the trigger just before the action query and drop it immediately afterwards) or a script that pairs the action query with an appropriate SELECT.
kimcord_99
2011-11-02 20:01:01 UTC
if you need to display rows you need another sql statement



"SELECT * FROM InvoiceCopy WHERE PaymentTotal <> 0""
2011-11-02 19:59:38 UTC
The query is correct. It updates the rows. If you want to view the changes, then you will need to SELECT them.



Good Luck!

If you need further assistance/advice, feel free to contact me.
AJ
2011-11-02 19:57:17 UTC
It won't display the records. All it will do is what it did, telling you the number of records affected.
fan
2011-11-02 20:11:58 UTC
mmmm


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...