Hi @Bobby P
How about change the WHERE filtering Clause
WHERE [DynamicsCRM.po_program].[rsm_dtpprogramid] = ' + @DynamicQuote
+ N'''10105''' + @DynamicQuote + N' AND [DynamicsCRM.rsm_emailnotification].[CreatedOn] >= '
+ @DynamicQuote + @DynamicQuote + @StartDateDeriveUTC + @DynamicQuote + @DynamicQuote + N')'
to this:
WHERE [DynamicsCRM.po_program].[rsm_dtpprogramid] =
'+ @DynamicQuote + N'''10105''' + @DynamicQuote + N' AND [DynamicsCRM.rsm_emailnotification].[CreatedOn] >= '
+ @DynamicQuote +convert(varchar(30), @StartDateDeriveUTC, 109) + @DynamicQuote + N')'
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
So did you add a PRINT to see how the final query looks like?
Since we only see fragments of the code, it is difficult to say what is wrong.
You may want to read this section from my article on Dynamic SQL to get tips on how to preserve your sanity when working with linked servers: https://www.sommarskog.se/dynamic_sql.html#remotedata.
Hi @Bobby P
Is there any update about this issue?