Forum Replies Created

Viewing 15 posts - 286 through 300 (of 428 total)

  • RE: Get list of months, monthname and Year

    ColdCoffee (9/4/2011)


    And coming to my code, a 0-based will throw the CASE statement out of sync. That's why i din't use it 🙂

    You're right, I had thought of that...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: if NULL ? ??

    Sean Lange (9/2/2011)


    ... but I still suggest you look into why you are using the nolock hint. It is ok and useful in some places but not always.

    I would have...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Get list of months, monthname and Year

    For even cleaner code, your method needs a 0-based tally table. This is easily accomplished by adding -1 to row_number(). Your code then looks like this:

    DECLARE @StartDATE DATETIME;

    SET @StartDATE =...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: SQL to return only rows that aren't distinct

    Instead of doing a where count(*) > 1 it is often faster to check for duplicates by looking for any rows for which you can find at least one other...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Same Date and Various Time Select in Single Row in sql server

    Like Dave suggested, use row_number(), then add a little math, a crosstab and some string manipulation...

    declare @tbl table (

    EmpCode int not null,

    ShiftDateTime datetime not...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Select where statement issue

    Let's throw in some "modern" commands (not that they do anything good to the performance).

    SELECT *

    FROM @Form

    except

    SELECT *

    FROM @Form

    WHERE FromID = 3 OR FromID = 4

    Note to OP:...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: combine string from multiple records

    Neither pivot nor cross-tab. Just a simple trick using for xml path(). Does any length of texts (up to varchar(max) - 1), and any number of rows.

    declare @tbl table (

    ...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Calculate component percents without a cursor

    Isn't the essence of your problem that you are trying to calculate off of percentages of a volume per shipment? In other words, shouldn't you store absolute quantities of the...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Please help with Merge statement understanding

    In this posting I presented an example on how to use a cte as the target for merge. The cte can be used to filter the rows to act upon...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: UPDATE statement with INSERT

    No, that is not the merge command OP is describing. OP describes some sort of 2-way merge, updating the first table when there is a match, inserting missing records from...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Join two views cause slow query.

    Without the internals of those views, their underlying tables and some test data we can not do much for you. Please provide some more details and people here will be...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: PIVOT result column format

    And if you must do the formatting in T-SQL, you could replace the pivot by a crosstab. Then you can use max(), which allows for character strings to be handled,...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: SQL 2008 - T-SQL query assistance

    I, for one, would be very interested to see a nested set implementation explained. I've read a lot about it and think it looks very promising, but I so far...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: please interpret sql clause

    Have a read at: http://msdn.microsoft.com/en-us/library/ms176057.aspx

    An excerpt of this page:

    "DBCC CHECKIDENT ( table_name, RESEED, new_reseed_value )

    Current identity value is set to the new_reseed_value.

    If no rows have been inserted into the...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

  • RE: Help with SQL Query

    Sean Lange (8/30/2011)


    You are going to have to join this table back to itself. This is pretty basic. give it a try and post back what you tried. Yes, I...



    Posting Data Etiquette - Jeff Moden[/url]
    Posting Performance Based Questions - Gail Shaw[/url]
    Hidden RBAR - Jeff Moden[/url]
    Cross Tabs and Pivots - Jeff Moden[/url]
    Catch-all queries - Gail Shaw[/url]


    If you don't have time to do it right, when will you have time to do it over?

Viewing 15 posts - 286 through 300 (of 428 total)