Forum Replies Created

Viewing 15 posts - 901 through 915 (of 2,463 total)

  • 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

  • RE: Are the posted questions getting worse?

    Brandie Tarvin (3/24/2016)


    <headdesk>

    One of my coworkers just came up with the worst joke ever.

    Three DBAs walk into a NoSQL bar. Soon after, they leave - they couldn't join a table!

    Will...

    "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: Split without delimiter based on postion into multiple columns

    I was curious and looked at the thread.

    ChrisM@home (10/22/2012)


    yuvipoy (10/22/2012)


    Ok, thanks. Can you give an example of how the data from this output table would be used please?

    ChrisM as...

    "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: indexes-non clustered

    db8 (3/23/2016)


    preparing T-SQL ,

    they told me we can sort by using ,with index clause.

    don't know what exactly use of this with index clause I will confirm on this...

    "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: FOR XML Path

    ringovski (3/23/2016)


    Thanks Orlando and Alan for the replies.

    Is dbo.splitcsv a reserved table or function somewhere as i am unable to find it within the DB?

    It's a custom, user-created function 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

  • RE: FOR XML Path

    Let's reformat the code to make it more readable:

    SUBSTRING

    (

    (

    SELECT ', ' + gen_Firstname + ' ' + gen_Lastname

    FROM...

    "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: Talking baseball

    Ray K (3/23/2016)


    Interesting.

    I won't say whether or not I believe it, but whether or not he actually does, that's his prerogative. ...

    "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?

    ChrisM@Work (3/23/2016)


    How many of you contractors have been so taken with a gig that you've signed up as a permie? I just did. I never expected that.

    The idea of presenting...

    "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: Counting

    This is my "get numbers" or "fntally" function which has served me well.

    I started with what I've learned from Jeff Moden including the 0 or 1 start functionality. Then added...

    "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: Avoid Blank Values in a column

    Stephanie Giovannini (3/23/2016)


    David McKinney (3/23/2016)


    A slight variation (although I've not got SQL installed to test it.)

    CONSTRAINT ck_xxx CHECK ('' not in (c1,c2,c3,c4,c5))

    Would you kindly check and let me...

    "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: Which indexes out of MISSING INDEXes report are most important to implement?

    Grant Fritchey (3/23/2016)


    Happy to help out. I'm rewriting the execution plans book. It should be done soon I hope.

    I finished your execution plan book while I was on vacation last...

    "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 - 901 through 915 (of 2,463 total)