Forum Replies Created

Viewing 15 posts - 136 through 150 (of 428 total)

  • RE: how to properly put variable into SQLString

    And also the global temp table is not needed at all. For example:

    DECLARE @dd1 datetime = dateadd(year, -1, getdate());

    DECLARE @SQLString NVARCHAR(4000);

    SET @SQLString = N'

    select t.name, t.object_id

    from sys.tables t

    where...



    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: how to properly put variable into SQLString

    You should not do any string concating. If you're going to use sp_executesql, then use it properly and specify the date as a parameter.

    DECLARE @SQLString NVARCHAR(4000)

    SET @SQLString = N'

    SELECT...



    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: Changing the auto-number/incremented value (not setting it back to 1)

    In fact, you will always have holes in the sequence. For example if you do a rollback after an insert, the value will not be reset, even though the row...



    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: Creating all possible combinations of two numbers of two columns without recursion or repeatation.

    If an exam question explicitly states "cross join is not allowed", they're probably asking for you to show that there is another 'construct' in SQL that accomplishes the same result...



    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: Combining union and union all

    Raghavendra Mudugal (3/8/2012)


    (from next time rather converting to image, it will be better to paste the exact SQL)

    Actually no. The code was intentionally presented as a picture for 2 reasons:

    1...



    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 multiple rows with subquery that use EXCEPT

    ladyblue1075 (3/8/2012)


    Hi,

    I'm writing a script that will update selected multiple rows of records I got from my EXCEPT select.

    I wrote this:

    UPDATE t1

    SET t1.col1 = t2.col1, t1.col2 = t2.col2, t1.col3...



    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: Combining union and union all

    To finalize this: My explanation is wrong and my question + answer was correct only by luck.

    The proper explanation has been given in this thread. To be sure I am...



    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: Combining union and union all

    tim.kay (3/8/2012)


    Got it right and thought that I understood - now looking at the other posts I am slightly confused.

    So am I, as I was very sure I had tested...



    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: Combining union and union all

    I see your point. I have to get back on this or maybe someone else sees what's wrong?



    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: Combining union and union all

    You have left off half of the explanation in your quote. In the next sentence the use of parenthesis to override this behavior is explained:

    To preserve duplicates in only a...



    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: Filtering IsNull Alternatives

    Provide us a table definition (so we can create a table similar to yours) plus a script to fill it with some test data. That way we can see for...



    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: Recursion - find last child

    This shows OldID 1 changed to NewID 12

    And so on, however, an Id can change more than once.

    Like OldID 5 went from 5 to 23, then 23 to 50.

    I did...



    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: How to use dynamic sql and prevent sql injection

    Or use a free proxy server somewhere on 'the net'. This article is an absolute 'must read' related to your work. You should not have to read it from home.



    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: Recursion - find last child

    The Cad-method assumes that the newID always higher is than the oldID. This may very well be true, given that the ID is likely implemented as an identity column, but...



    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: Where clause troubles with variables

    Disregarding the fact that indeed create date is normally before the modification date, it is easy to determine the latest of two (or more) date values from a single row...



    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 - 136 through 150 (of 428 total)