Stored procedure question - Compile vs runtime

  • I gave the wrong table in the SP it compiled fine and gave me run time error. Again i gave the wrong column name for a table it throws compile time error.

    This seems to be conflicting. Can anybody explain me ?

  • for objects...tables,procs or views, a feature of stored procedure is delayed name resolution...of the object doesn't exist at creation time, it still compiles, but will fail at execution time.

    so you can create procs out of object dependancy order, and they are still "ok" later.

    columns do not have that feature...only their parent object...so the algebraizer finds the object(table or view) but raises the error becase the column doesn't exist.

    it's the behavior of SQL server.

    the work around is to use dynamic SQL if you are referencing non-existant columns yet.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Go it, Thanks Lowell 🙂

    ek

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

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