Stored Procedure

  • Hi All,

    I have a stored procedure XYZ which contains local cursors for processing data. XYZ will retrn a set of records

    I want to call   XYZ in a stored procedure ABC and do some other processing with the returned data. So I created a temperory table in ABC and used INSERT INTO #Tmp....EXEC XYZ.

    When I execute ABC, some times it will show error messages. It is showing 'Invalid column name...' in XYZ

    If I run XYZ and try to run ABC in Query Analizer, it will work.

    If I restart sql server and try to run ABC, it will show the error.

    Anybody know why it is happening and how can we solve it

  • Does your stored procedure depend on a view?

    If the structure of the underlying tables for a view alter then the view can get confused as to which columns to retrieve. Try sp_refreshview on any views and sp_recompile on your stored procedure.

  • Are you inserting like this??

    Insert into dbo.MyTable (Col, Col2, Col3) exec dbo.MySP

    ..cause if you're not specifying the columns of the insert you can have a lot of problems.

  • ...cause if you're not specifying the columns of the insert you can have a lot of problems

    Even more problems than the use of a cursor will cause?

    What about getting rid of the cursor in the first place?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Forgot to mention that... I gues it's a given to me by now...

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

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