Forum Replies Created

Viewing 15 posts - 1,606 through 1,620 (of 3,957 total)

  • RE: Find number in String and Return INT

    Many ways to skin this proverbial cat:

    WITH Buyers (buyer) AS (

    SELECT '3, RRRRR'

    UNION ALL SELECT '4, SSSSS'

    UNION ALL...

  • RE: Need Help In Query ....

    To get exactly the expected results you specified, a very minor modification to Koen's query is in order:

    DECLARE @minDate DATE = '2010-01-01';

    DECLARE @maxDate DATE = '2013-04-01';

    SELECT DATEADD(mm,6 * number,@mindate)...

  • RE: Case statements advice - query case field?

    Alan.B (8/12/2013)


    dwain.c (8/12/2013)


    Alan.B (8/12/2013)


    Instead of the case statement you can also do this:

    SELECT ISNULL(thing1.name,(ISNULL(thing2.name,thing3.name))) AS name

    And why not:

    SELECT COALESCE(thing1.name,thing2.name,thing3.name) AS name

    ?

    Nice. That is cleaner and easier to read.

    +1

    I confess...

  • RE: Is overpunch amenable to cross apply?

    Is it too late for me to join the party?

    WITH SampleData (A, B) AS (

    SELECT *

    FROM (VALUES

    ('0002137}','0004000{')

    ,('0002137J','0004000A')

    ,('0002137K','0004000B')

    ,('0002137L','0004000C')

    ,('0002137M','0004000D')

    ,('0002137N','0004000E')

    ,('0002137O','0004000F')

    ,('0002137P','0004000G')

    ,('0002137Q','0004000H')

    ,('0002137R','0004000I')

    ,('0002137{','0004000}')

    ,('0002137A','0004000J')

    ,('0002137B','0004000K')

    ,('0002137C','0004000L')

    ,('0002137D','0004000M')

    ,('0002137E','0004000N')

    ,('0002137F','0004000O')

    ,('0002137G','0004000P')

    ,('0002137H','0004000Q')

    ,('0002137I','0004000R')

    ) a(A,B))

    SELECT OldA=A, A=STUFF(A, LEN(A), 1, (A1-1)%10)*POWER(-1, CASE WHEN A1 > 9 THEN...

  • RE: Case statements advice - query case field?

    Alan.B (8/12/2013)


    Instead of the case statement you can also do this:

    SELECT ISNULL(thing1.name,(ISNULL(thing2.name,thing3.name))) AS name

    And why not:

    SELECT COALESCE(thing1.name,thing2.name,thing3.name) AS name

    ?

  • RE: Do I need to use cursors for this?

    Sounds like you're looking for a way to build a catch all query in the SP.

    Take a look at this article by Gail Shaw: SQL-in-the-Wild: Catch-all queries[/url]

  • RE: Stumped on Query

    I'm not sure about your question on the joins but using the sample data provided by Geoff, here's my solution (with the "instance" column):

    with

    raw_data (id, customer_id, product, [date]) as

    (select 1,...

  • RE: Are the posted questions getting worse?

    ChrisM@Work (8/12/2013)


    Jeff Moden (8/10/2013)


    Brandie Tarvin (8/2/2013)


    How many people (besides Jeff and myself) have written SQL Spackle articles?

    How many SQL Spackle articles are there?

    Yes, I have a reason for asking. But...

  • RE: Are the posted questions getting worse?

    Jeff Moden (8/10/2013)


    Brandie Tarvin (8/2/2013)


    How many people (besides Jeff and myself) have written SQL Spackle articles?

    How many SQL Spackle articles are there?

    Yes, I have a reason for asking. But I...

  • RE: Are the posted questions getting worse?

    ChrisM@Work (8/9/2013)


    dwain.c (8/8/2013)


    ChrisM@Work (8/8/2013)


    Howard - the name of the guy made me chuckle, given the pidgin English 😀

    I've been hearing a lot of Tok Pisin for the last week....

  • RE: Are the posted questions getting worse?

    ChrisM@Work (8/8/2013)


    Howard - the name of the guy made me chuckle, given the pidgin English 😀

    I've been hearing a lot of Tok Pisin for the last week. Two...

  • RE: Pass inter year and month return last day of month

    How about this?

    WITH SampleData AS (

    SELECT Yr=2012, Mon=7, DesiredDate=CAST('07/31/2012' AS DATETIME)

    UNION ALL SELECT 2014, 6, CAST('06/30/2014' AS DATETIME))

    SELECT Yr, Mon, DesiredDate

    ...

  • RE: help with incrementing

    ck9663 (8/6/2013)


    How about something with no CTE nor subquery...

    ...

    ~~ CKK

    ?? Mine has neither. The CTE is only there to put the sample data someplace.

  • RE: Are the posted questions getting worse?

    Stefan Krzywicki (8/6/2013)


    ... but don't know if MySQL has any reasons to avoid it like the plague.

    Any opinions?

    Perhaps because it's owned by Oracle?

  • RE: How to convert my cursor tsql to set based

    Still would like to see some test data with expected results.

    This sounds very similar to a problem I worked out not too long ago. And for that I had...

Viewing 15 posts - 1,606 through 1,620 (of 3,957 total)