Forum Replies Created

Viewing 15 posts - 8,221 through 8,235 (of 8,731 total)

  • RE: Text To Decimal Values

    Scott, your code is giving me an error, but I corrected it by using only string functions.

    STUFF(LEFT(REPLACE(SomeVal, '.', '') + '000000', 5), 4, 0, '.')

  • RE: Formatting date of birth using South African ID number

    Dixie's solution seems simple, but won't work for dates before 1950.

    I've done this that would work for any date between today and 100 years in the past (almost).

    And a simple...

  • RE: COALESCE - 2

    I had to read twice to realize that there was a COALESCE(NULL, NULL).

    It's good to know how this is wrong, but it shouldn't be in real code. Why would someone...

  • RE: Text To Decimal Values

    This might help you, considering your second post. But you won't be able to use a decimal(3,2), I'm assuming you meant decimal(5,2) that will support values like 499.99

    ;with data (SomeVal)...

  • RE: Finding min and max date within a sub-group

    A simple reply is enough, there are no extra points for correct answers.

    When you spend more time in this forum, you'll find out that answers that might seem correct, could...

  • RE: SQL Query Help.....

    This might help you, however, you need to understand what is doing before implementing it.

    It was great that you posted DDL and sample data.;-)

    ;WITH rCTE AS(

    SELECT 1 AS level,

    AccountName,

    GroupName,...

  • RE: Finding min and max date within a sub-group

    Ron,

    Even if the Excel file is better than an image, it's not the best option to post sample data.

    There are people that won't download any files (due to company policies...

  • RE: substring

    That's basically the same that I posted, with a simple mistake based on the difference of the behaviour of LEN and DATALENGTH.

    DATALENGTH won't work fine with trailing spaces or unicode...

  • RE: substring

    A simple improvement on Sean solution.

    ;with SampleData (val) as

    (

    select '51079-216-20' union all

    select '3456-435623-45-34'

    )

    SELECT REPLACE( LEFT( val, LEN( val) - 2), '-', '')

    FROM SampleData

  • RE: Insert of multiple rows of fixed data erroring with Incorrect syntax near ','

    That was implemented on SQL Server 2008.

    In 2005 or previous versions, you need to use several inserts or Selects with UNION ALL. Example:

    insert COSTING (ID,GROUP1,ROUP2,GROUP3)

    SELECT 'ACS1-1-0010','ACS1-2-0010','ACS1-3-0010','' UNION ALL

    SELECT 'ACS1-1-0020','ACS1-2-0010','ACS1-3-0010',''UNION ALL

    SELECT...

  • RE: How to write Update query for this scenario

    I can help you to write the update statement. But I would like to know why are you doing this? This will help you with 3 days but what happens...

  • RE: Group by with MAX then other columns - how to control what is returned if there are multiple results

    ryan.mcatee (11/6/2012)


    There are probably many ways to do this, and I'm not sure this is the proper way, but this is how I do queries like this:

    That can help you,...

  • RE: Finding min and max date within a sub-group

    CELKO (11/6/2012)


    Does your boss draw pictures when he wants to give you programming specs?

    🙁 Unfortunately, yes. However, he pays me to use the pictures and we're all volunteers...

  • RE: Near Friday Date

    Assuming you have DATEFIRST set to 1, change GETDATE() to your date value.

    DATEADD( dd, 5 - DATEPART( dw, GETDATE()), GETDATE())

  • RE: Pivot with sum of multiple columns

    Have you tried the Cross tabs method?

    It's in the link provided by Charles. I find it much easier to understand and apply.

Viewing 15 posts - 8,221 through 8,235 (of 8,731 total)