Forum Replies Created

Viewing 15 posts - 1,891 through 1,905 (of 2,462 total)

  • RE: Select Unique Customers per month for last 2 years..

    Sean Lange (9/11/2014)


    Alan.B (9/10/2014)


    months as

    (

    select 1 as MoNo, 'January' as Mo union all

    select 2 as MoNo, 'February' as Mo union all

    select 3 as MoNo, 'March' as Mo union all

    select...

    "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: Select Unique Customers per month for last 2 years..

    months as

    (

    select 1 as MoNo, 'January' as Mo union all

    select 2 as MoNo, 'February' as Mo union all

    select 3 as MoNo, 'March' as Mo union all

    select 4 as MoNo,...

    "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: SSMS 2012 appears to be very buggy

    I love SSMS 2012 and have not had any of the issues you describe. I'd reinstall or repair ssms.

    "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 replication replicate index rebuild ?

    SQL Guy 1 (9/10/2014)


    Hi all.

    We have transactional replication. We have a index rebuilding job on publisher, but subscriber is still highly fragmented.

    Should we create defragmentation job on subscriber, or...

    "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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    Steve Jones - SSC Editor (9/10/2014)


    Jeff Moden (9/10/2014)


    Solomon Rutzky (9/9/2014)


    In the end, isn't this why Microsoft gave us CLR Integration?

    Heh... yeah... just like they gave us the ability to write...

    "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: Select records based on two dates

    I will also recommend Gail's article.

    The logic for your query will look like this (note that you did not detail the expected behavior for if only @enddate has 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: Check the Variable is Empty or Null

    IF @user > '' --This checks for not null and not empty

    Cool. I never knew you could do that, very interesting :laugh:

    Edit: sql code tag messed up my "greater than"...

    "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: Identify the missing element [Query]

    Ok, I had a few minutes to kill. There will be a little more work to get this to work with what you have done thus far.

    The Function:

    CREATE FUNCTION...

    "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: Identify the missing element [Query]

    I don't have access to a pc at the moment otherwise I would give a better example...

    You could accomplish this using a splitter and splitting the strings using the space...

    "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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    To be fair, Microsoft did give us master data services which has a CLR udf splitter (an awful one) that still requires enabling CLR on so most DBAs just say...

    "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: Becoming a DBA inSQL

    First, for what it's worth - I started as a network guy and moved into SQL because I loved it (I liked Cisco). I even took a little pay cut...

    "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: Tally OH! An Improved SQL 8K “CSV Splitter” Function

    gbritton1 (9/3/2014)


    I'm using the splitter (just downloaded the zip file) and noticed something odd. Dunno if its just me, but check this out:

    select * from dbo.[DelimitedSplit8K](' ', ' ')...

    "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: Understanding Joins !!!

    I am having some problem understanding joins (Specially left,right and outer apply)when it comes to more then 3 tables.... which result set is formed first and then second...

    When you join...

    "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: Need help in SP

    First I would see if the query returns anything when you replace

    o.StatusID in (Select osl.val from dbo.SplitStringToIntegerArray(@OrderStatusList, ',') osl ) and

    o.OrderTypeID = 1

    with

    where o.OrderTypeID = 1

    If you...

    "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: joining 2 selects where a value not in Values

    If I understand your question correctly you need to do what is referred to as a Left Anti Join Semi Join.

    There are a couple ways you can do this:

    DECLARE...

    "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 - 1,891 through 1,905 (of 2,462 total)