0 Please review this SQL query, designed to provide DateTime to transactions with none stored 1 Michael Garrison posted 9 Years Ago I have a need to routinely add a TransactionDateTime to our Credit Card transactions, as they're not automatically stored, and also not being inputted by our accounting team. Since this is potentially so fraught with peril, I'd love for a few eyes to check my logic before I start attempting to run this. The idea is it finds transactions which belong to a closed batch, that doesn't have a TransactionDateTime. Then it grabs the StartDateTime from the batch itself and writes that data as the TransactionDateTime (almost all our batches are single day batches, so that is nearly always accurate- and in any case is better than a null TransactionDate). Here's my first draft: UPDATE [FinancialTransaction] SET [FinancialTransaction].[TransactionDateTime] = b.[BatchStartDateTime] FROM ( SELECT [Id],[BatchStartDateTime],[Status] FROM [FinancialBatch] ) b WHERE b.[Id]=[FinancialTransaction].[BatchId] AND [FinancialTransaction].[TransactionDateTime] IS NULL AND b.[Status]=2 Thoughts? Thanks!
Michael Garrison 9 years ago Thanks David- I use Joins for selects but honestly wasn't familiar with that particular syntax of Update. Looks cleaner, I think I'll take it =)Thanks again
Michael Garrison 9 years ago Oh, and I'm not sure that a GitHub issue is necessary- the transactions don't have dates because our accounting team doesn't provide them- figuring that having put the date into the Batch is sufficient.