Forum Replies Created

Viewing 15 posts - 166 through 180 (of 476 total)

  • RE: Parsing out a string field

    Hi

    Not sure if I have the rules correct here, but I have applied the following:

    Strip anything before and including the first hyphen

    Strip anything after and including the second hyphen...

  • RE: SQL Function to remove excess characters

    And yet another variation:-)

    SELECT DISTINCT LEFT(OrderNo, ISNULL(NULLIF(CHARINDEX('-',OrderNo,CHARINDEX('-',OrderNo)+1) - 1,-1),LEN(OrderNo)))

    FROM (

    SELECT 'SO-123456' AS OrderNo

    UNION ALL

    SELECT 'SO-123456-01'

    UNION ALL

    SELECT 'SO-123456-2'

    UNION ALL

    SELECT 'SO-123457'

    UNION ALL

    SELECT 'SO-123457-1'

    UNION ALL

    SELECT 'SO-123457-02'

    UNION ALL

    SELECT 'SO-123458') x

  • RE: Parse, Convert, Convert back and Insert

    Really that isn't a great deal different from what I posted. My biggest concern is with the portion to parse the date out of the string. RIGHT(Descr, PATINDEX('%[0-9]%',Descr...

  • RE: Problem changing the structure my table

    cesarscorp2 (3/4/2014)


    Thanks everybody and excuse me for my bad explication.

    mickyT is just that I needed. Thanks a million! 🙂

    No problem, glad to help

  • RE: Parse, Convert, Convert back and Insert

    Hi

    You just need to CONVERT back once you've added 14 days, so 'some string' + CONVERT(VARCHAR(8), yourupdateddate,1)

    As a note, I would use the DATEADD function and make you pattern...

  • RE: Problem changing the structure my table

    Hi

    This looks like a pivot question to me. I've made a couple of assumptions here that may be incorrect, so you may want to change it to suit.

    Also have...

  • RE: Geeky Entertainment

    I wouldn't mind seeing The Dwarves by Markus Heitz done.

    +1 on David Eddings series, I think The Redemption Of Althalus would make a great movie

  • RE: Nearest match, is this possible ?

    mick burden (3/2/2014)


    MickyT, can you explain

    UPDATE POSTCODESTEST SET Location = Geography::Point(Latitude, longitude, 4326)

    especially 4326, also how to convert your code into a working SP please

    The 4326 reference is...

  • RE: CTE where amount is > +- 10%

    Hi

    You could wrap your percentage calculation up in an absolute and just check that it's greater than 10.

    ...

    AND ABS((CAST(ProductionCnt.Count AS FLOAT) - CAST(avgcnt.Count AS FLOAT)) / CAST(avgcnt.Count AS FLOAT) *...

  • RE: SQL Insert with Identity value AND incremental rollover column ?

    The problem I see with your procedure is that the @mbatch variable is not set to the max.

    If you alter your procedure to the following it should work.

    CREATE PROCEDURE [prMTRANS_INSERT]

    ...

  • RE: Nearest match, is this possible ?

    Hi

    You could always use the Geography datatype for this. I've taken your sample and added a primary key, geography column and indexed it. This should work on 2008+.

    This...

  • RE: previous months data

    The EOMONTH is a function to return the End Of Month. So to return the last six months excluding the current month you could do something like:

    WHERE loyaltystartdate >=...

  • RE: previous months data

    How do you want pick you months? It's the 21st Feb, do you want rows from February to be included? Do you want complete months regardless of the...

  • RE: previous months data

    born2achieve (2/20/2014)


    Hi Micky,

    Thanks for your reply and from your sample query there is no logic to get last 6 moths data. i just gave the sample data. my actual...

  • RE: previous months data

    Hi

    I think a full outer join with a sum on the coalesced values may do the trick for you

    with Companyloyalty as (

    select 1 as idloyalty, 1000 as company, 100 as...

Viewing 15 posts - 166 through 180 (of 476 total)