sql server - T-SQL: How to use parameters in dynamic SQL? -


I have the following dynamic query which is working fine without the WHERE section, which is expected uniqueIdentifier .

When I pass it, I do not get the result. I tried CAST and CONVERT , but no results. I am doing it wrong, can anyone help?

  Purchase Process [dbo] [SP_Test1] / * 'b0da56dc-fc73-4c0e-85f7-541e3e8f249d' * / (@p_CreatedBy UNIQUEIDENTIFIER) DCLAR @ SQL NVHAR (4000) SET @ SXL = 'DECLARE @ p_CreatedBY UNIQUEIDENTIFIER SELECT DateTime, created by topic, Created by Time, Subject, ROW_NUMBER () Date was compiled in the form of date (according to date time) == p_Created / * & lt; --- The problem is in this condition / /) New data table 'AECEPXXsUsUsCLSLL  

You must have the sp_executesql parameter.

... created WHERE = @ P ... EXCUTE sp_executesql @sql, n '@P UnifiedEditifier', @ P = @ P_BuddedBY

Comments