Dynamic SQL calls

  • Comments posted to this topic are about the item Dynamic SQL calls

  • Nice, easy question to end the week on, thanks, Steve

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Good question, thanks Steve.

    ...

  • Considering how much dynamic SQL I write where I work, this was a very easy question.  I use sp_executesql extensively in my code where I need to run dynamic SQL.

  • It seems to me the second answer could be correct as well.  If the DECLARE statement included a value for @CustomerKey then the query won't error.  So, if the second DECLARE statement was changed to:
    DECLARE @params NVARCHAR(1000) = '@CustomerKey int = 101';
    Then the query wouldn't error out and would return rows if there were rows containing a customer key of 101.

  • +1 to johnfowler. While adjusting the @params statement to include a fixed value may not be very useful, it still works.

    • This reply was modified 5 years ago by  RLilj33.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply