Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    India
    Posts
    5

    Question Unanswered: Need help with PREPARE statement within a stored procedure.

    Hi,
    Am a relatively new guy to DB.
    I need to use the PREPARE command within a stored procedure.
    When i write the following
    EXEC SQL PREPARE query_stmt FROM 'select * from emp_info'
    I get the following error
    Server: Msg 170, Level 15, State 1, Procedure bsp_rpt_EmployeeReport, Line 10
    Line 10: Incorrect syntax near 'query_stmt'.
    Can anyone guide on how to use the PREPARE command within a stored procedure.

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Use
    --------------------------------------------------------------------
    declare @variable varchar(400)
    select @variable = 'select * from emp_info'
    exec @variable
    --------------------------------------------------------------------


    will work

Posting Permissions

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