Exactly in what part of the code you are trying to use that? E.g. when I want to pass 'like' parameter to WHERE clause, I declare @variable varchar(50) and within procedure I put (...)WHERE [name] like CONCAT('%',@variable,'%')(...) and then variable is used in LIKE statement, but it seems like you should use EXEC(...)''WHERE',' @WHERE') (which is not the best name for variable, to be honest). General rule - if you are passing anything to EXECUTE or sp_executesql it should be string, to be functional within exec. Test it out using PRINT insted of exec first - if it prints a valid query (which you can e.g. copy from output and run) it will be working. If it is not a valid string - your idea will collapse. Shortly: If you can PRINT it, you can EXEC it.
Claro, simple y al grando. Los TQM.
Bless you, that was super clear!
Thanks ❤❤❤
DO's: implement this on your own local machine for your own research
DONT's: use dynamic sql in an api
Tq so much
Chindi explanation
Tumba Thanks
I guess I understand how it works but why not explaining why we need it??
Incroyable.
I can think with a use for it in reports. Using dynamic SQL to have a a flexible report that shows columns only when they have values in them.
very good
how to pass a varchar field to where criteria like
DECLARE @Where [nvarchar](50)='FirstName=' +'Nancy''
return error "Invalid column name ''Nancy"
Exactly in what part of the code you are trying to use that?
E.g. when I want to pass 'like' parameter to WHERE clause, I declare @variable varchar(50) and within procedure I put
(...)WHERE [name] like CONCAT('%',@variable,'%')(...) and then variable is used in LIKE statement, but it seems like you should use EXEC(...)''WHERE',' @WHERE') (which is not the best name for variable, to be honest).
General rule - if you are passing anything to EXECUTE or sp_executesql it should be string, to be functional within exec. Test it out using PRINT insted of exec first - if it prints a valid query (which you can e.g. copy from output and run) it will be working. If it is not a valid string - your idea will collapse.
Shortly: If you can PRINT it, you can EXEC it.
💕💕
Well that helped me
Love from Pakistan
it's blurred