Results 1 to 2 of 2

Thread: Running SQL instruction stored in @variable

  1. #1
    Dmitry Guest

    Running SQL instruction stored in @variable

    Does anybody know how I can run some SQL Server instruction stored in variable in stored procedure (for instance @var = 'SELECT AuthorName FROM Authors&#39. I need it for creating dynamic sql select queries.

  2. #2
    Ivo Guest

    Running SQL instruction stored in @variable (reply)

    hi dmitrij
    You must call it EXEC(@var)
    But you cannot access for example local variables in @var, defined outside @var.
    bye


    ------------
    Dmitry at 8/12/01 7:03:31 AM

    Does anybody know how I can run some SQL Server instruction stored in variable in stored procedure (for instance @var = 'SELECT AuthorName FROM Authors&#39. I need it for creating dynamic sql select queries.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •