+ Reply to Thread
Results 1 to 5 of 5

Adding a new column to an exisaiting SQL Database using VBA in Excel

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Adding a new column to an exisaiting SQL Database using VBA in Excel

    Hi All
    I was wondering whether anyone can help me with the following :

    I want to add a new column to an existing external SQL database and I have the following code so far (I am new to this and not sure if this is the right way)
    Please Login or Register  to view this content.
    Is this correct way and if so what is the command in adding a new column (field) to the existinf database , I want to call the new column Brand which is text with 60 characters

    Hope this is clear

    Tanks in advance

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Adding a new column to an exisaiting SQL Database using VBA in Excel

    Why do you want to do it in VBA? structural changes probably aren't best done here.

    Nevertheless, it's just SQL so the syntax would be something like:
    Please Login or Register  to view this content.

    So:
    Please Login or Register  to view this content.
    Though you'd obviously need to swap the placeholders with actual values

  3. #3
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Adding a new column to an exisaiting SQL Database using VBA in Excel

    Thanks for the reply. The reason I need to do it in VBA is because I have an excel spread sheet where the reporting is done and it contains lots of other macros and VBA codes.

    I will try your suggestion

    Tanks again

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Adding a new column to an exisaiting SQL Database using VBA in Excel

    I think you're making a mistake, but I wis you all the best

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Adding a new column to an exisaiting SQL Database using VBA in Excel

    See this article. It addresses MS-Query primarily but it has a section on rewriting SQL (the command string), "on the fly" using Excel Tables and the SUBSTITUTE command. I've even used this technique to switch from one database table to another within the same database, and used a model list on a spreadsheet to generate a bunch of "variable" IN statements for the SQL.

    http://www.utteraccess.com/wiki/index.php/MS_Query
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. If mySQL database column entry matches excel column entry, then...
    By khelza in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2015, 02:34 PM
  2. matching inputted names in excel column with the closest possible name in the database ws
    By TaskinRahman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-23-2012, 11:41 PM
  3. excel vba to separate single column entries into database format
    By antaga082 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2012, 11:33 PM
  4. Match data between CSV and database and update column in database table
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2012, 05:59 PM
  5. Last record is not adding to database
    By ramserp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2009, 08:43 AM
  6. Replies: 5
    Last Post: 06-11-2006, 04:45 PM
  7. [SOLVED] how do you send a email from an specific excel column (database)..
    By Email from database in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1