Forum Replies Created

Viewing 15 posts - 691 through 705 (of 3,957 total)

  • RE: t-sql use two cte

    Lynn Pettis (3/6/2014)


    wendy elizabeth (3/6/2014)


    In existing t-sql 2008 that I need to modify, there is already an existing cte that looks like the following:

    ;WITH rCust AS ( SELECT...

  • RE: t-sql use two cte

    Sean Lange (3/6/2014)


    select * from SomeTable;;;;;;;;;;;;;;;;;;;;;;;

    That is the SQL equivalent of "you're terminated sucker!" 😛

  • RE: Filter Records In Table

    Excuse me from horning in here, but ROW_NUMBER() is overkill for this:

    WITH SampleData (m,d) AS

    (

    select 'MachineA', '1/1/2008'

    union all select 'MachineA', '1/3/2008'

    ...

  • RE: Split a pipe delimited string into two columns

    There's no reason to call DelimitedSplit8K twice, even if it is super-efficient (bless its heart):

    WITH SampleData (s) AS

    (

    SELECT 'XYZ00001|Test_b|XYZ00002|Test_a|XYZ00003|Test_c'

    )

    SELECT s

    ,Col1=MAX(CASE WHEN ItemNumber%2...

  • RE: How to divide number

    ScottPletcher (3/6/2014)


    If the original amount is odd, add 1 cent to the first joint account holder. That will work regardless of the number of joint account holders:

    select cast(original_amount/2 +...

  • RE: Are the posted questions getting worse?

    TomThomson (3/6/2014)


    Koen Verbeeck (3/6/2014)


    MysteryJimbo (3/6/2014)


    Koen Verbeeck (3/5/2014)

    Pfff, than you have never been in Belgium before 😀

    If we wouldn't be having the most traffic jam congested cities in the world, you...

  • RE: SQL Function to remove excess characters

    SQLRNNR (3/6/2014)


    dwain.c (3/5/2014)


    This could be done in a possibly more general fashion using DelimitedSplit8K but if you've only got 1 or 2 hyphens, you can also do it like this:

    WITH...

  • RE: Calculate and return the previous Date at 18:00 Hours

    ChrisM@Work (3/6/2014)


    dwain.c (3/4/2014)


    ChrisM@Work (3/4/2014)


    SELECT DATEDIFF(dd,0,GETDATE())-1

    SELECT DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0)

    SELECT DATEADD(hh,18,DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,0))

    Use q3. q1 and q2 help explain the algorithm.

    I can do it with just two date function calls:

    SELECT DATEADD(dd,DATEDIFF(dd,0,GETDATE())-1,'18:00')

    I can also name that tune...

  • RE: Windowed Function in Where Clause

    OK thanks. My head was spinning like Linda Blair's in The Exorcist trying to work out the possibilities. 😛

  • RE: Convert consecutive rows with a date to date range

    Hi All,

    Maybe I'm too late to the party but I can add a bit of value here.

    I recently did some testing of this in SQL 2012 (where there is a...

  • RE: Remove duplicates from Multiple colums please help me

    Insert into Table 2 the results from this query:

    WITH SampleData (D1, D2, D3, D4, D5) AS

    (

    SELECT 1, 4, 4, 2, 3

    )

    SELECT D1=MAX(CASE WHEN rn1=1 THEN D...

  • RE: Windowed Function in Where Clause

    Maybe this is a silly question but:

    select Person

    , OrderingKey = row_number() over (order by Person)

    from #OrderingTest

    order by row_number() over (order by Person) desc

    What's the difference between...

  • RE: SQL Function to remove excess characters

    This could be done in a possibly more general fashion using DelimitedSplit8K but if you've only got 1 or 2 hyphens, you can also do it like this:

    WITH SampleData (OrderNo)...

  • RE: Combining keys to create a master list

    I don't know anything about fuzzy grouping in SSIS but doesn't this do what you want?

    WITH SampleData (key1, key2) AS

    (

    SELECT 64794, 2600014

    UNION...

  • RE: The SQL TABLE Type: Beyond Table-Valued Parameters

    louie1487 78804 (3/5/2014)


    Great article indeed! I only problem with TVP is that Microsoft didn't include an ALTER TYPE. If I need to alter a TVP, I need to drop it...

Viewing 15 posts - 691 through 705 (of 3,957 total)