Facebook Twitter Instagram
    Facebook Twitter Instagram
    Xlbasics
    • General
    • Text Editors
      • Notepad++
      • Sublime Text
    • Resources
      • Books
    • Write for Us
    Xlbasics
    Home » General » How to use Excel Spreadsheet to generate SQL statements
    General

    How to use Excel Spreadsheet to generate SQL statements

    By SandiNo Comments3 Mins Read
    Excel Spreadsheet to generate sql statement
    Share
    Facebook Twitter LinkedIn Pinterest Email

    This article explains how to use Excel to generate SQL statements like drop table, insert and update easily using built-in CONCATENATE excel function.

    Microsoft Excel is one of the most used product in the IT Industry for project management and tracking. It is a great product. You can use it to do simple tasks and even create a game. Here I will share a simple tip to generate repeating SQL statement using Excel. 

    Before going further let’s discuss concatenate function in Excel.

    CONCATENATE

    It is built-in excel function to concatenate multiple strings into on single sting.
     For example:

    • =CONCATENATE(“Hello “, A2, ” How are you “)

    A2 – is replaced with cell data. Assume A2 – Tom. It will show Hello Tom How are you.

    Argument name Description
    text1    (required) The first item to join. The item can be a text value, number, or cell reference.
    Text2, …    (optional) Additional text items to join. You can have up to 255 items, up to a total of 8,192 characters.

    Drop statement using Excel

    Let’s assume a random set of data which contains table information like table name, owner, and other information. Now you want to drop all or all the selected tables. One way is to write a logic using PL/SQL and use execute immediate statement. You can also use a text editor like Notepad++ and copy and paste to create commands.

    How to achieve this using less effort?

    Drop table syntax

    DROP TABLE table_name;

    1. Open excel which has table information as shown below.

    sample dummy table data

    2. Select E2 or any black cell.

    3. Write an excel concatenate function as shown below.

    =CONCATENATE("DROP TABLE",A2,".",B2)

    4. Copy and paste or click and drag this formula to all cells.

    That’s it and your script is ready.

    enter excel formula

    You can use the same method to generate more complex scripts for insert, update and delete.

    Insert statement using Excel

    Using the same approach you can create insert statement as shown in below image.

    Insert statement syntax

    INSERT INTO table_name(column_name....) values (values...);
    
    

    excel to generate insert statement

    Check the image to create the excel sheet and use formula.

    = CONCATENATE(A2,B2,",",C2,D2)

    Below is generate insert clause

    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);
    INSERT INTO dummy_insert(dummy_1,dummy_2) values (1,2);

    Summary

    Not a great Tip, but this has helped me a lot during Inventory Support, where I need to apply multiple mundane fixes daily.

    I hope you find this helpful. Do you have any such small trick? Do share in the comments section below?

     

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleQuery to get current executing statement in Oracle concurrent program
    Next Article Awesome Screenshot – (How to) Install and Capture Images, Record Videos
    Sandi
    • Website
    • Twitter

    I am Oracle Certified Associate(OCA) working in Oracle Domain since last 15 Years. Started this blog to share knowledge about different Technologies mostly focussing on Oracle.

    Related Posts

    What is chrome://net-internals/#dns? Clear or flush DNS Cache on Chrome

    What is 5G? Impact, Advantages. Is it game Changer?

    How to Use Google Input Tools Chrome Extension

    Add A Comment

    Comments are closed.

    • Facebook
    • Twitter
    • YouTube
    • LinkedIn
    Latest Posts

    What is chrome://net-internals/#dns? Clear or flush DNS Cache on Chrome

    Unleashing the Power of MIME Tools in Notepad++

    Zoom in and Zoom out in Notepad++

    Show/hide Hidden, Control, Special Characters in Notepad++ (Show Symbol)

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    • Popular Posts
    XAMPP Control Panel - Manage/Configure Apache, MySQL, FileZilla, Tomcat, Mercury

    XAMPP Control Panel – Manage/Configure Apache, MySQL, FileZilla, Tomcat, Mercury

    How to create Hyperlink and Bookmark in Microsoft Word

    Install Vanilla Forum on Windows local host

    How to Install Vanilla Forum Software on Windows 10

    XML Tools Plugin for Notepad++

    XML Tools Plugin for Notepad++ – Features, Download, How to Install

    Facebook Twitter Instagram Pinterest
    • Chrome
    • XAMPP
    • Forums
    • Notepad++
    • Privacy Policy
    • About
    © 2023 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.