• Navigation
Results 1 to 5 of 5
  1. #1
    Banned.

    Join Date
    Oct 2006
    Posts
    10,115
    BG Level
    9

    SQL Query improvements/optimization/etc

    Right so I'm a complete noob when it comes to SQL so expect my explanation to be sub par, anyway, onto the question.

    We have the usual customer 'database' in Excel of course that needs to be migrated to SQL (MS-SQL). The problem comes with a table that stores:

    [PrimaryKey] [ProductID] [PriceID] [Price]

    [ProductID] can have multiple [PriceID]s

    The Excel file on the other hand comes in the format:
    [Product Number] [Price1] [Price2] [Price3] ... [PriceN]

    I tried with a query (both for update and insert new data) that did it all in one go. But it took forever.

    Now I'm trying with a while bucle 1 row at a time, it is still taking forever (forever as in 1hr.+) but its only 30,000 rows of data (well 30,000 * PriceN) but still I don't think its too much data for it to take so long. Hell I could just transpose the data in Excel in 20 minutes of work or work something out with the import package thingie.

    Basically wondering if there is an easier/faster way to do the import with a query; or if you know of a forum/site/book to un-noob myself it'll be appreciated.

    Edit: Ok so the bucle method took 30 or so minutes to show some results.

  2. #2
    Pandemonium
    Join Date
    Oct 2005
    Posts
    7,839
    BG Level
    8
    WoW Realm
    Cho'gall

    Dumb question but is the Excel document on the SQL server? The reason it's taking so long could just be because it's reliant on your network speed. Otherwise Excel > SQL is a pretty straightforward process

  3. #3
    Banned.

    Join Date
    Oct 2006
    Posts
    10,115
    BG Level
    9

    Yeah I'm running it all locally. Turns out all I had to do was add a CASE WHEN ... end. Cut the time from 1hr to like 30 seconds ._.
    I don't know why they guy that did the script in the first place did it the derp way the first time around.

  4. #4
    Relic Horn
    Join Date
    Dec 2007
    Posts
    3,411
    BG Level
    7
    FFXIV Character
    Purrrfect Lee
    FFXIV Server
    Hyperion
    FFXI Server
    Cerberus

    Quote Originally Posted by Tajin View Post
    forum/site/book to un-noob myself
    Not gonna happen.

  5. #5
    Banned.

    Join Date
    Oct 2006
    Posts
    10,115
    BG Level
    9

    happy new year to you too bish ._.