Forum Replies Created

Viewing 15 posts - 46 through 60 (of 2,462 total)

  • Reply To: Ordering by Alias

    Good one Steve!

    "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

  • Reply To: Introduction to the Partition By Window Function

    MVDBA (Mike Vessey) wrote:

    a great start - I use rownumber over (partition by order by) a lot

    one of the more overlooked windowing fuctions though is NTILE - especially when you are dealing...

    "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

  • Reply To: Using Graph Theory To Group Records

    Absolutely brilliant! I love this article. Well done. Five stars.

    "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

  • Reply To: working days

    Sue_H wrote:

    Alan Burstein wrote:

    Sue_H wrote:

    You would probably want to create a calendar table when you also want to exclude bank and national holidays since those can vary by country, company 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

  • Reply To: working days

    That function looks like a horror movie and it's not even Halloween yet.  The function below, ifn_workdays, is what you need. It does not handle holidays. Here's an example 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

  • Reply To: How can I force a select statement NOT to use a specific index ?

    It would be cool if there were a WITHOUT keyword.

    ...

    FROM <table> WITHOUT (INDEX(<index(s) you dont want to use>))
    "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

  • Reply To: Tsql/SP Code Optimization

    Redgate SQL Prompt is useful for this kind of thing. It's not as intuitive as you would describe but it will help you identify unused variables, parameters and columns, which...

    "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

  • Reply To: select several lines randomly according to several categories

    And thanks to your lack of netiquette, we have no DDL.

    I think what I posted should answer the OP's question as well as yours Joe.

     

    "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

  • Reply To: select several lines randomly according to several categories

    You can use TOP and ORDER BY NEWID() like this:

    -- Sample data
    DECLARE @yourdata TABLE
    (
    Family INT,
    Room INT,
    subfamily INT
    );
    INSERT @yourdata VALUES (1,5,6),(2,5,7),(3,5,7),(4,2,3),(4,2,4);

    -- Number of Rows
    DECLARE @rows INT...
    "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

  • Reply To: The Scientific Method: a call to action

    . This particular article, well I regret reading and discussing it. Yet again, SSC disappoints.

    I would ask for your money back.

    "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

  • Reply To: SSRS Interview

    As already mentioned - you don't want to pass other people's experience off as your own. I would never hire someone who did this nor would I respect someone who...

    "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

  • Reply To: Are the posted questions getting worse?

    "UK to stay in Interrail scheme after U-turn"

    ba dum chhh

    "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

  • Reply To: week startdate and enddate

    Speedy Pletcher beat me to it... More details about the requirement are in order. Here's my solution:

    DECLARE @startDate DATE = '20181230', @endDate DATE = '20191230';

    WITH
    E1 AS...

    • This reply was modified 7 years ago by Alan Burstein. Reason: Forgot ORDER BY
    "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

  • Reply To: Is there CLEAN function, or similar, similar to the Excel function>

    PatExclude or PatReplace can do the trick.

    For example, this will remove any characters that are not alphanumeric while preserving spaces (note the space after the "Z"):

    "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

  • Reply To: Is there any justification for really using SQL CLR

    Old thread, I know but there is something that has not been discussed here that I think is super important. Correctly designed CLR scalar UDFs don't have the problems that...

    "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 - 46 through 60 (of 2,462 total)