up vote 0 down vote favorite
share [g+] share [fb]

I have two columns with two values.. I want to append some text to the left of all the cells of Column A and concatenate to the right of all the cells of Column B.

Basically I'm trying to avoid having to type in a whole bunch of sql updates. so for example if i have an excel with

ID Employee Name

135 Rasputin
76 Bush

I want to generate something like this

UPDATE EMPLOYEES SET ID = '135', WHERE employee_name= 'RASPUTIN'
UPDATE EMPLOYEES SET ID = '76', WHERE employee_name= 'BUSH'

So perhaps a solution of appending text to the cells and then merging the rows?

I prefer a built in function as I'm not familiar with VBA thanks!

link|improve this question

60% accept rate
What SQL/Server version? DB2/MSSQL/Oracle? – Dog Ears Oct 14 '09 at 14:13
feedback

1 Answer

up vote 2 down vote accepted

Assuming ID is in in Column A and Employee Name is in Column B

Try this: ="UPDATE EMPLOYEES SET ID = '" & A1 & "' WHERE EMPLOYEE = '" & B1 & "'"

in column C row one and then copy the contents of the cells down to generate SQL for each update.

Note: there's no comma before the WHERE.

link|improve this answer
Cool That works! :D – ayrad Oct 14 '09 at 14:23
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.