[RESOLVED] Bulk Insert into sql-VBForums
Results 1 to 6 of 6

Thread: [RESOLVED] Bulk Insert into sql

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    129

    Resolved [RESOLVED] Bulk Insert into sql

    Hi

    Looking for some advice and maybe an example.

    basically I have an Access Database that im opening into a datatable in VB

    I then want to save this data into a SQL table. Now there are roughly 80,000 records in this table, and this will need ot be done fortnightly.

    I can't just move the access db over to SQL as im not allowed

    Is there an easy way of doing this from VB? as this is going to run as part of a bigger process. I know It could be done using import feature in sql but the person that will be running this won't have access to sql

    thanks in advance

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Bulk Insert into sql

    What version of SQL Server you are using. SQL Server 2005 supports 'BULK INSERT' command, otherwise you can insert multiple rows like this in one go:

    INSERT INTO MyTable (FirstCol, SecondCol)
    VALUES (‘First’,1);
    INSERT INTO MyTable (FirstCol, SecondCol)
    VALUES (‘Second’,2);
    INSERT INTO MyTable (FirstCol, SecondCol)
    VALUES (‘Third’,3);
    INSERT INTO MyTable (FirstCol, SecondCol)
    VALUES (‘Fourth’,4);
    INSERT INTO MyTable (FirstCol, SecondCol)
    VALUES (‘Fifth’,5);

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    129

    Re: Bulk Insert into sql

    Im using SQL2005

    How do you go about using the Bulk Insert (sorry ive just never used it before)

  4. #4

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    86,138

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    129

    Re: Bulk Insert into sql

    cheers jmcilhinney thats spot on with a little tweaking

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.