Forum Replies Created

Viewing 15 posts - 886 through 900 (of 2,458 total)

  • RE: Calendar Table Function

    Nice work, well done sir. A few things to note:

    First a couple of ticky-tacky things that aren't a huge deal but worth mentioning...

    You may want to consider using a...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: By date

    If you had a calendar table available the you can do it like this (note my code and comments):

    USE tempdb

    GO

    -- Simplified calendar table with only the columns you need

    IF OBJECT_ID('dbo.calendar')...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Creating Combined Queries

    Phil Parkin (3/29/2016)


    Alan.B (3/29/2016)


    You would use AND.

    SELECT vend_id, prod_id, pro_price

    FROM products

    WHERE prod_price <=5

    AND vend_id IN (1001, 1002);

    Disagree. This requires an OR.

    select a from b where condition1

    union (should probably be union...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Creating Combined Queries

    You would use AND.

    SELECT vend_id, prod_id, pro_price

    FROM products

    WHERE prod_price <=5

    AND vend_id IN (1001, 1002);

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: issue with single quotes in the column values

    Can you include some DDL and sample data?

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Does it make a sense to use parallelism for single HD drive ?

    SQL Guy 1 (3/28/2016)


    And about the value for threshold for parallelism, you recommend to do some research. Can I ask what should I check for it?

    I am not an...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Does it make a sense to use parallelism for single HD drive ?

    SQL Guy 1 (3/28/2016)


    I have a complex query with multiple joins and conditions. My test server has only one drive for data. Same for production.

    Estimated execution plan inserts...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Running Totals with window function

    Jacob Wilkins (3/28/2016)


    DesNorton (3/28/2016)


    Thank you Sachin and Jacob. From my initial dev testing, this appears to do the trick. Now we see if the QA team can break...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Trigger Happy

    Great article Andy, well done.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: MDX Book Recomendation

    Jon.Morisi (3/25/2016)


    I bet there's only 2 to pick from, if you can even find one. :hehe: BI books in general have been hard to come by since 2008...

    Yep.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Running Totals with window function

    Jacob Wilkins (3/25/2016)


    Sachin Nandanwar (3/25/2016)


    ...But again it looks to cumbersome with all those conditions in the CASE expression.Your original solution is more subtle.

    Your version doesn't have to be that complicated.

    It...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Are the posted questions getting worse?

    Anyone want to take a stab at this. Essentially the OP needs a csv splitter that handles text qualifiers; Eirikur Eiriksson's RFC-4180 compliant splitter from this article: This article[/url] would...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Processing strings.

    Are you really on SQL Server 2008? If you were using SQL 2012 this article would get you 90% there:

    http://www.sqlservercentral.com/articles/SQL+Server+2012/106903/%5B/url%5D

    I'm going to play around with a couple ideas and...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: sql and stored procedure

    John Mitchell-245523 (3/24/2016)


    Those somewhat contrived requirements make this sound like a homework assignment. Why can't you create any temp tables or new procedures?

    John

    This is actually a common business requirement....

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • RE: Dynamic Lag Function

    Provided that the rank_pos is sequential and there are no gaps you use LEAD like this:

    SELECT t.Score, Rank_pos = ISNULL(t.Rank_pos,X.Rank_pos+1)

    FROM

    (

    SELECT score, Rank_pos, xx = LEAD(Score,1,1) OVER...

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

Viewing 15 posts - 886 through 900 (of 2,458 total)