query works outside stored procedure

  • I had a similar problem with SP3a where the stored procedure would work IF it had no parameters, otherwise it would take 50x as long to complete.

    I would check your version

  • Can you post the SP?

    How are you running the SP? Via a job?

    Are there any error messages in SQL Server Error Log or the Windows Event Viewer Logs?

    -SQLBill

  • Have you tried stepping through the stored procedure in SQL query analyser?

    Right click on the offending procedure within the Object Browser and you will see "Debug" at the bottom of the menu.

    If your underlying table structure has changed since the stored procedure was written then you will need to do an sp_recompile on the tables that have changed.  This will force all dependent stored procedures/views to recompile to take account of the new structure.

    Similarly use sp_refreshview on views.

Viewing 3 posts - 1 through 4 (of 4 total)

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