I have a google Sheets that looks like this :
ID | City | Capital | Country
-------------------------------
5 | Paris | Yes | France
8 | Madrid| Yes | Spain
I would like to find a way to generate this kind of code for each line
update database set city='Paris' and Country='France' where id=5
IF @@ROWCOUNT=0
insert into database(city,country) values('Paris','France');
I would like to generate a big file that concatenate all the SQL queries like the one above (one for each row), so I can just update my database with this.
CodePudding user response:
try:
="update database set city='"&B2&"' and Country='"&D2&"' where id="&A2&"
IF @@ROWCOUNT=0
insert into database(city,country) values('"&B2&"','"&D2&"');"