ANmaSQL_InsertStatement

Creates SQL INSERT statements from a table in Excel.
Used to be executed to move data from Excel to SQL (or MySQL) database.
You need to run the macro while Excel table sheet is open, as always, can refer to workbook, sheet and startup cell in call.
Sheet should have table columns headers as 1st row (refer to attached screenshot).
Additional Sub is provided to save Insert statements (1 per row) into text file.
Edit 2024-01-15: Adding SQLTest2() function to save generated SQL Inserts into text file with support for non-English characters (like Arabic).
Edit 2024-05-25: Adding brackets for column names and fix issue with last comma.

CodeFunctionName What is this?

Public

Tested

Original Work

Access is limited.

Login here using your Linkedin account. to see or download code.

No registration, not another password to remember, login using your Linkedin account and have access to all public codes in Boldcodes.com

Linkedin Login

SQLTableName, Optional Shee = "Active", Optional Wb = "This", Optional StartCell = "A1"

Sub TestSQL1()
    ' Use to output into .sql file for large tables
    Open "D:\Docs\Links v2.sql" For Output As #1
    Print #1, ANmaSQL_InsertStatement("ANmaCCLinks")
    Close
End Sub

Views 477

Downloads 138

CodeID
DB ID