Forum Replies Created

Viewing 15 posts - 46 through 60 (of 221 total)

  • RE: SSIS Package creates corrupt rar file

    bugg (8/28/2015)


    Stephen Beaven-479566 (6/17/2010)


    I have a SSIS package running on 2 of our live servers (Windows Server 2003 Enterprise x64 Edition SP2) which creates an excel spreadsheet and then compresses...

  • RE: SSIS Package creates corrupt rar file

    Stephen Beaven-479566 (6/17/2010)


    I have a SSIS package running on 2 of our live servers (Windows Server 2003 Enterprise x64 Edition SP2) which creates an excel spreadsheet and then compresses it...

  • RE: Combined Ranking

    Okay this is the best solution I could come up with:

    DECLARE @fruit_shop TABLE (shop NVARCHAR(10))

    INSERT INTO @fruit_shop VALUES ('shop1'), ('shop2')

    DECLARE @tmp TABLE (fruit VARCHAR(50), shop VARCHAR(10), preference INT, InStock...

  • RE: Combined Ranking

    Hi All,

    I've added in a stock check which will override preference if all stock can be found in one location

    CASE WHEN s.InStock >= p.OrderQuantity THEN 1 ELSE 0 END DESC

    Which...

  • RE: Combined Ranking

    ChrisM@Work (6/25/2015)


    Yes, or this which looks a little cleaner:

    SELECT

    rn = ROW_NUMBER() OVER(PARTITION BY s.fruit ORDER BY s.Preference),

    max_rn = COUNT(*) OVER(PARTITION BY s.fruit),

    s.*,

    p.OrderQuantity

    INTO #StreamedData

    FROM @tmp s

    INNER JOIN @purchase p...

  • RE: Combined Ranking

    Try creating MAX(rn) in the source table #StreamedData: COUNT(*) OVER(PARTITION BY ...) - it's "cleaner" and probably much cheaper 😎

    Something like this:

    SELECT *,max(rn) over(partition by fruit) AS max_rn INTO #StreamedData

    FROM

    (

    SELECT...

  • RE: Combined Ranking

    ChrisM@Work (6/24/2015)


    I wonder how a rCTE version would fare, in terms of performance?

    Very cool 🙂

    I've amended the code to pull in unassigned order quantities similar to spaghetti's output 🙂

    DECLARE @tmp...

  • RE: Combined Ranking

    spaghettidba (6/24/2015)


    Maybe this?

    DECLARE @tmp TABLE(fruit VARCHAR(50),shop VARCHAR(10),preference INT, qty INT)

    INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 1',1 ,4)

    INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 2',2 ,3)

    INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 3',3 ,5)

    INSERT INTO @tmp(fruit,shop,preference,qty)...

  • RE: Combined Ranking

    Thanks , I think what I need to try do is assign the cant find fruit to a new "shop" which will be pending stock.

    So keep everything how it is...

  • RE: Combined Ranking

    There is always a final hurdle! :crying:

    I've hit a issue where if there isn't enough stock at shop i get less then the actual desired quantity. I need to...

  • RE: Combined Ranking

    spaghettidba (6/19/2015)


    Ah, great. Glad I could help.

    Might sound like a weird question, but: is this really a database for selling fruit? 🙂

    🙂 not fruit but selling other products, I...

  • RE: Combined Ranking

    spaghettidba (6/19/2015)


    I assume you didn't see my latest attempt. It should solve your speed issues.

    Yep spotted it , just testing it now .. You are a legend!!! thank you for...

  • RE: Combined Ranking

    spaghettidba (6/19/2015)


    Sorry, I repeated my tests and yes, it's dog slow 🙂

    Yep it slows right down when there are 1000's at each shop. :laugh:

    Do you think if I split the...

  • RE: Combined Ranking

    spaghettidba (6/19/2015)


    I think that you should explode your stock quantity using a tally table.

    This should do:

    DECLARE @tmp TABLE(fruit VARCHAR(50),shop VARCHAR(10),preference INT, qty INT)

    INSERT INTO @tmp(fruit,shop,preference,qty) VALUES ('orange','shop 1',1 ,1)

    INSERT INTO...

  • RE: Combined Ranking

    Thanks , I'm really struggling to get my head around this.

    Is there no way I can keep a running decreasing balance of the the fruit wanted with the...

Viewing 15 posts - 46 through 60 (of 221 total)