• easy_goer (10/13/2013)


    Hello. I have a portion of a table that looks like what I've listed below. This is just a small subset of the data that I'm attempting to retrieve, but this displays what the structure looks like. What I would like to do is have a script that can pull all but the top two lines. So, I want to get everything that's below the line that contains "E-Mail". Hope this makes sense.

    I don't see a line that says E-Mail.

    You'll find many more people willing to help if you start by providing DDL and consumable sample data for your problem. Like this:

    DECLARE @T TABLE

    (

    Column1 INT

    ,Column2 INT

    ,Column3 VARCHAR(20)

    ,Column4 INT

    );

    INSERT INTO @T

    SELECT 8106, NULL, 'Top', 8106

    UNION ALL SELECT 22701,8111,'Test2',8106

    UNION ALL SELECT 26892,22701,'Extra1',8106

    UNION ALL SELECT 26893,22701,'Extra2',8106

    UNION ALL SELECT 26894,26892,'ExtraSub1',8106

    Without a better explanation of what you're trying to do, all I can do is take a shot in the relative dark.

    SELECT *

    FROM

    (

    SELECT *, rn=ROW_NUMBER() OVER (ORDER BY Column1)

    FROM @T

    ) a

    WHERE rn > 2;

    This returns all of the rows after the second.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St