October 15, 2013 at 9:29 am
I am new to sql and would like your help. I have a table that lists an payroll reference number for all the workers in the business. for example
Emma Davies 01234568
Jo Bloggs 45685214
I need to update the Payroll_reference filed so they all start with EA. So after update is will be
Emma Davies EA01234568
Jo Bloggs EA45685214
I have used this but it did not work. Any ideas please?
Update pdcontacts
set Payroll_ref = 'EA' + 'Payroll_ref'
October 15, 2013 at 9:32 am
emdavies82 (10/15/2013)
I am new to sql and would like your help. I have a table that lists an payroll reference number for all the workers in the business. for exampleEmma Davies 01234568
Jo Bloggs 45685214
I need to update the Payroll_reference filed so they all start with EA. So after update is will be
Emma Davies EA01234568
Jo Bloggs EA45685214
I have used this but it did not work. Any ideas please?
Update pdcontacts
set Payroll_ref = 'EA' + 'Payroll_ref'
You've quoted 'Payroll_ref', so that makes it a literal string. Your essentially said: -
Update all Payroll_ref columns to "EAPayroll_ref".
Try: -
BEGIN TRANSACTION;
UPDATE pdcontacts
SET Payroll_ref = 'EA' + Payroll_ref;
--Check results
SELECT *
FROM pdcontacts;
--Rollback changes
ROLLBACK;
--COMMIT;
--Comment out ROLLBACK and uncomment COMMIT when you're happy that this does what you expect.
October 15, 2013 at 9:39 am
Thank you so much for the fast response 🙂
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply