Forum Replies Created

Viewing 15 posts - 436 through 450 (of 4,080 total)

  • RE: Convert Date List to Date Range

    santiagoc93 (7/9/2016)


    with Mycte

    as

    (

    select ROW_NUMBER()over(order by id)as c, t.* from ##TEST as t

    )

    select t1.DT as "startDate", t2.DT as "endDate"from Mycte as t1

    left join Mycte as t2

    on t1.ID =t2.ID and t1.c=t2.c-1

    Just...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    J Livingston SQL (7/8/2016)


    Zidar (7/8/2016)


    Obviously, we need more constraints. What we have so far is OK, but we need more. Time permitting, new post is coming this afternoon, if not,...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    Hey Zidar, here is the function and check constraint to avoid overlap. Can't guarantee it's flawless, I just knocked it out during a break.

    I presume you are...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    How to enforce 2 or 3?

    CREATE UNIQUE INDEX IX_#subscriptions ON #subscriptions (SubscriberID, UnsubScribedDate)

    will work for our example where the definition of an active subscription is one without an UnsubscribeDate....

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    Thank you for putting in the effort to create the constraints.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Case statement confusion

    A CASE expression is an expression, just like a formula or function.

    Its logic produces a single scalar value.

    It is not another version of...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Maintaining Sequence of OUTPUT rows during INSERT

    Yes, the MSDN documentation on it isn't very clear, but you can find it on the OUTPUT Clause page in the section on Arguments.

    I see it in the syntax...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    I don't have time to write a paper at the moment, so this will have to suffice. 🙂

    I've read Mr. Celko's books, and I have seen some truly execrable flat...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Convert Date List to Date Range

    If you have the ability to change your transactional code I would suggest this, only because subscriptions are always paired with cancellations.

    create table ##TEST (ID int, SubscribeDate date, UnsubscribeDate date)

    New...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Case statement in order by

    If result.Ip_Code is a number, you could always use it's negative in place of DESC

    CASE WHEN result.Pc_CrFCIC IN (52, 53) THEN result.Ip_Code ELSE -result.Ip_Code END,

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Maintaining Sequence of OUTPUT rows during INSERT

    Found one: http://sqlblog.com/blogs/rob_farley/archive/2012/06/12/merge-gives-better-output-options.aspx

    Stefanie, not sure why I missed reading your message with the sample code I wanted. But thanks to you as well.

    Thanks to you all.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Maintaining Sequence of OUTPUT rows during INSERT

    Drew, that sounds like the answer to a maiden's prayer, and I'd like to remember it for future reference, but after reading your note I looked at the MSDN pages...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: remove values from between quotes

    DECLARE @Inputs TABLE (RowID INT IDENTITY(1,1) PRIMARY KEY, TextString VARCHAR(100))

    insert INTO @inputs

    VALUES ('SELECT * from client where id = ''789546'' and county = ''Northants''')

    ,('select * from client where id =...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Maintaining Sequence of OUTPUT rows during INSERT

    TheSQLGuru (7/7/2016)


    So then the question becomes can you hold off creating the B-table rows until you have acquired all that you need to populate them without doing a post-insert update?...

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • RE: Maintaining Sequence of OUTPUT rows during INSERT

    drew.allen (7/7/2016)


    If you change your INSERT to a MERGE, then you can just OUTPUT the original GUID. Of course, the MERGE introduces it's own problems.

    Drew

    I'm not following you, Drew....

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

Viewing 15 posts - 436 through 450 (of 4,080 total)