• you just need to replace the select-command with an delete-command, followed by the table to delete the data from. Then remove the order-by-clause and that's it.

    delete from dbo.BC_ShiftSummaryInfo

    from dbo.BC_ShiftSummaryInfo A

    Join dbo.BC_ShiftSummary B

    On A.SS_ID = B.SS_ID

    Where B.ShiftStartDate between '20121214 06:00:00.000'

    and '20121214 22:00:00.000'

    If ure are still not sure use a BEGIN TRANSACTION at the beginning and a ROLLBACK transaction at the end of the command. This way you get the number of deleted records without actually deleting the records.

    When using the OUTPUT-command you can even see which records would have been deleted:

    BEGIN TRANSACTION

    delete from dbo.BC_ShiftSummaryInfo

    output deleted.*

    from dbo.BC_ShiftSummaryInfo A

    Join dbo.BC_ShiftSummary B

    On A.SS_ID = B.SS_ID

    Where B.ShiftStartDate between '20121214 06:00:00.000'

    and '20121214 22:00:00.000'

    ROLLBACK TRANSACTION

    When sure the command is doing what you want just replace the ROLLBACK with a COMMIT and the delete operation is finally executed.

    Something off topic:

    As you may have seen I removed the "-" from the datetime-strings. You should do that too in future scripts. When using the format "YYYY-MM-DD" the date can be interpreted in the us-english oder british-english(or german) format, switching the day and the month. It's enough to have different default language set for a user or a connection.

    So always use the format "YYYYMMDD". It is always interpreted the same way independent of the language settings.