Forum Replies Created

Viewing 15 posts - 241 through 255 (of 1,468 total)

  • Reply To: How to get different time between every row and previous row

    The display that you are seeing is the format of the time data type.  You should not be formatting the data in SQL - That is the job of the...

  • Reply To: How to get different time between every row and previous row

    You have not provided the format that you need the time difference in, so I am providing it as [time].

    However, this will not cater for values greater than 24 hours.

  • Reply To: what i do to enhance this statement select into ?

    Below are 2 alternative ways to write the same query, but without the LEFT JOIN.  They may have an improvement in performance, so test, test, test.

    SELECT ...
  • Reply To: Update Column but with Distinct Values

    This will work with the sample data that you provided

    WITH cteData AS (
    SELECT t.Id
    , t.CarID
    , t.CarStatus
    ...
  • Reply To: Best Practice question

    Option2 is going to give you terrible performance because the @Name = '', @zip = '' and @colors = '' in the WHERE clause will force a table scan every...

  • Reply To: show data for today only

    With no readily available test data, I would try to edit the 1st CTE as follows

    ;with ClockIn as
    (select [Initial],[RFID],[Time] as ClockInTime from Data where Type=1 and [Time]...
  • Reply To: How to insert data to target table when there is no matching and update if has

    asita wrote:

    Thank you DesNorton,

    I got that, my question was how can I incorporate that in this single statement, that null values update always need to check for all columns, if...

  • Reply To: How to insert data to target table when there is no matching and update if has

    You could use ISNULL for your update, so that it does not replace existing values with NULL.

    Something like this ....

    UPDATE dest
    SET dest.Value = ISNULL(src.Value, Dest.Value)
    FROM SourceTable AS...
  • Reply To: Are the posted questions getting worse?

    Brandie Tarvin wrote:

    Brief tangent into real SQL stuff...

    Has anyone ever heard of table triggers not firing for every row if you do set-based updates to records?

    Our vendor sent us code for...

  • Viewing 15 posts - 241 through 255 (of 1,468 total)