Churn SQL Code with Excel | Excel Hacks | Kovolff

Опубликовано: 04 Ноябрь 2024
на канале: kovolff
229
5

Excel can be pretty useful when you need to generate SQL statements for Excel data to bei inserted, updated or deleted from a SQL database.

Just use Excel’ text concatenation capabilities to build your SQL statements from scratch

Simple concatenation
= A2&” “&B2

This concatenates cell A2 with cell B2 and adds a space between both values
Similarly you can build your SQL string.

A typical INSERT code would look like this
="INSERT INTO demo_table(["&$A$1&"], ["&$B$1&"], ["&$C$1&"], ["&$D$1&"], ["&$E$1&"]) VALUES('"&A2&"', '"&B2&"', '"&C2&"', '"&D2&"', '"&E2&"');"

$A$! Is an absolute cell reference meaning that it does not change when the formula it is in gets copied to the cells below via Autofill.

You can convert normal cell references ie A2 to absolute cell references ie $A$2 simply by clicking on the F4 key.

Data is a small subset from https://world.openfoodfacts.org/data
Licence: https://opendatacommons.org/licenses/...

#excel #sql #hacks