Forum Replies Created

Viewing 15 posts - 1,636 through 1,650 (of 2,171 total)

  • RE: Sum or aggregate operation......

    How are you importing the CSV file?

    Almost always let SQL Server to decide how to convert data. You don't have to do it in most cases...

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Expert Must see this Update Statment

    Are you using a CASE sensitive collation?

    update title

    set year = 1999 , month = 11

    where ucase(category) = ucase('ENG') and number between 1550 and 1560

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Spreading Cost over Time period

    Since we do not know the source DDL, we'll have to guess.

    Something similar to

    SELECT Col1,

    SUM (CASE WHEN DATENAME(month, Col2) = 'january' then Col3 else 0 END) AS [January],

    SUM (CASE...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Date/Time 00:00

    A datetime is really a 4 byte datatype. Don't rely on formatting.

    If you are worried add a single ":00" for seconds trailing the column.

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Sequential Ordering of a Column

    DECLARE

    @Sample TABLE (Name VARCHAR(10), SortOrder INT)


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Incorrect syntax near '''','''' in sql string

    I count the lines

    1

    2

    3

    4 Found it!

     

    @xadProgramID,  --<---- This line needs a data type.

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Date problems

    SELECT

      CONVERT(VARCHAR, CURRENT_TIMESTAMP, 112),

            


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Return next available product value

    DECLARE

    @Sample TABLE (data VARCHAR(20))

    INSERT

    @Sample

    SELECT


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Sequential Ordering of a Column

    Make use of the new ROW_NUMBER() function available in SQL Server 2005.

    And depending on your business rules, RANK() or DENSE_RANK() would be helpful too.

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: DELETE all records except most recent

    A lot in impressive information! Well done.

    What does it say?

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: DELETE all records except most recent

    This is the execution plan with your method

      |--Hash Match(Inner Join, HASH[t2].[SomeID])=([t1].[SomeID]), RESIDUAL[tempdb].[dbo].[#BigTest].[SomeID] as [t1].[SomeID]=[tempdb].[dbo].[#BigTest].[SomeID] as [t2].[SomeID]...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Stored procedures for reading, with or without the join?

    It depends.

    What is your goal? What are you trying to do?

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: DELETE all records except most recent

    I didn't mean to be offensive either.

    I thought it would be proper to point out that OP wanted only one record left for each group.

    The problem description is vague and...


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: DELETE all records except most recent

    I know your method is fast!

    But there is one caveat.

    If there are duplicate records over SomeID and SomeDate, there will be duplicates left in the table.

     


    N 56°04'39.16"
    E 12°55'05.25"

  • RE: Puzzler: Three consecutive rows

    Amit, add this test data to the existing one.

    SELECT

    7, '2007-03-09', 'Doe' UNION ALL


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 15 posts - 1,636 through 1,650 (of 2,171 total)