Author |
Topic |
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-09 : 14:49:17
|
I have the following query:insert into payroll (Employeenumber, TotalRegHours, TotalOT)UPDATE Payroll SET payrolldate = CURRENT_TIMESTAMP, payrollran = 'Yes',approved = 'Yes'but I'm getting a syntax error near Update. Can someone please advise? |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-02-09 : 15:00:03
|
What are you trying to do? An insert or an update?You haven't specified anything to insert.insert into payroll (Employeenumber, TotalRegHours, TotalOT)VALUES(value1, value2, value3); Are you trying to update every row? Because that is what the update you have will do. |
|
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-09 : 15:08:40
|
actually what I'm trying to do is select all from a table I already have, insert it into my payroll table and then update. Is that possible? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-09 : 15:34:47
|
Tara,Thank you but I just noticed something, when I update payrolldate, I don't need to update the entire column. I guess what I need to check for is if there's a date in there already, and then update the new information with the current timestamp. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-09 : 16:08:02
|
Here's what I have:insert into payroll (Employeenumber, TotalRegHours, TotalOT)select * from scratchpad7Update PayrollCASE WHEN payrolldate IS NULL THEN CURRENT_TIMESTAMP ELSE payrolldate END, payrollran = 'Yes',approved = 'Yes' |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
dougancil
Posting Yak Master
217 Posts |
Posted - 2011-02-09 : 16:36:26
|
Thank you Tara. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|