Forum Replies Created

Viewing 15 posts - 2,806 through 2,820 (of 4,087 total)

  • RE: XML PATH QUESTION

    I did a quick comparison of Eirikur's and my methods. Here are the results:

    1) Eirikur's method shorts the first row, because he starts with 1 rather than 0.

    2)...

  • RE: XML PATH QUESTION

    Here is a different approach using a zero-based tally table. I've used a CTE to create a tally table, but you can skip that if you already have a...

  • RE: How to extract overlapping date ranges from a table of date ranges

    I set up some sample data (only one subscriber) and come up with the following:

    WITH Subscriptions AS (

    SELECT *

    FROM (

    VALUES

    (1, CAST('2014-01-01' AS DATE), CAST('2014-03-01' AS DATE))

    ,(1, '2014-02-01', '2014-05-01')

    ,(1, '2014-04-01', '2014-06-01')

    ,(1,...

  • RE: how to transform field name to attrribute value in for xml query

    Yes it is, but in doing so, your field tag now contains integer and character data, so you will have troubles shredding it later.

    Select

    ca.doc

    From Main

    Left Join Docs on...

  • RE: Adding quotes to dynamic SQL

    The easy way to do this is to create the results that you are looking for and then globally replace all of the single quotes with two single quotes before...

  • RE: Insert and Select statements

    If you are inserting col4 into col1, don't you want to use (col6 + col4)?

    Drew

  • RE: Hi Folks

    Phil Parkin (2/9/2016)


    What was the point of this?

    The response marked as a solution does not reference your table at all.

    I thought that response was brilliant when I saw that it...

  • RE: Rewrite the statement

    Ken McKelvey (2/9/2016)


    IF (@date IS NULL)

    SET @day = (SELECT MAX(day1) FROM table1 WHERE date1 = (SELECT MAX(date1) FROM table1));

    ELSE

    SET @day = (SELECT MAX(day1) FROM table1 WHERE date1 = @date);

    I believe...

  • RE: How to over come from outer apply

    No, it's still a breaking change.

    SELECT *

    FROM (

    VALUES(CAST(NULL AS DATE), CAST('2016-01-01' AS DATE)),

    ('2015-12-31', '2015-01-01'),

    ('2016-12-31', '2016-01-01')

    ) AS mc(TerminationDate, EffectiveDate)

    ORDER BY ISNULL(mc.TerminationDate, mc.EffectiveDate) DESC

    SELECT *

    FROM (

    VALUES(CAST(NULL AS DATE), CAST('2016-01-01' AS DATE)),

    ('2015-12-31', '2015-01-01'),

    ('2016-12-31',...

  • RE: IF or WHILE statements with Stored Procedures

    TJT (2/5/2016)


    @Results returns

    387961

    387962

    You're confusing the RETURN status with the RESULT SET. Since @Results is an integer, it CANNOT contain two separate numbers. The RETURN status can be specifically...

  • RE: IF or WHILE statements with Stored Procedures

    TJT (2/5/2016)


    OK, but even when I try this it doesn't work

    IF @Results > 10

    PRINT 'Hello'

    ELSE

    PRINT 'OK thanks'

    You need to be more specific. We need to know what the value...

  • RE: Double plus ungood

    Jacob Wilkins (2/4/2016)


    drew.allen (2/4/2016)


    Jacob Wilkins (2/4/2016)


    Unary plus and negative: https://msdn.microsoft.com/en-us/library/ms174362.aspx

    Cheers!

    EDIT: I must say that it is still strange that the unary plus works with string data, since the documentation specifies...

  • RE: How to over come from outer apply

    Hugo Kornelis (2/5/2016)


    ChrisM@Work (2/5/2016)


    ORDER BY MC.TerminationDate, MC.EffectiveDate DESC

    I didn't go over all your modifications, but this one just struck my eye.

    I think you intended this to be:

    ORDER BY MC.TerminationDate DESC,...

  • RE: Double plus ungood

    Jacob Wilkins (2/4/2016)


    Unary plus and negative: https://msdn.microsoft.com/en-us/library/ms174362.aspx

    Cheers!

    EDIT: I must say that it is still strange that the unary plus works with string data, since the documentation specifies numeric data. However,...

  • RE: Double plus ungood

    + can be either a binary or unary operator. The first one is the binary operator and the second is the unary operator.

    Drew

Viewing 15 posts - 2,806 through 2,820 (of 4,087 total)