How to exec SQL instruction stored in @variable

  • Does anybody know how can I execute SQL instruction that stored in local variable. For example @var='SELECT AuthorName from Authors'. Variable stoging gives me ability to create dynamic queries.

  • Check out sp_executesql in SQL Server's Books On Line. This allows you to execute a sql statement or batch that you have built. An alternative would be to use the EXECUTE statement.


Viewing 2 posts - 1 through 1 (of 1 total)

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