Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I use excel to generate a large update sql statement?

Tags:

sql

excel

I know there's a way to have insert statements within excel. Is there one for update? so far I've managed to come up with my update statement in SQL, but I have 6000 rows to update:

= "Update table Set name = " & A1 & " Where namefk = " & E2 & ""

Basically, I want the name and namefk to be populated with fields in my excel..but I can't seem to get it right. Any help will be appreciated.

like image 668
ShaunK Avatar asked Jan 17 '14 04:01

ShaunK


2 Answers

= "update table set name = '" & B1 & "' where namefk = '" & A1 & "'"

where column A1 has name fk & B1 have name You can drag the formula to achieve query to update thousands of records :) You can look into the link with the Example excel Hope it helps

like image 177
Hasya Avatar answered Oct 20 '22 21:10

Hasya


=CONCATENATE("update Site set SiteName='",D13,"' where Place='",A13,"' and Code='",B13,"'")

As per above we can make update query dynamically and if we make for one row after that we need to drag down, so automatically it will take column values.

like image 24
Pankti Shah Avatar answered Oct 20 '22 21:10

Pankti Shah