• Nice question! thanks.

    sam.dahl (8/26/2012)


    Secondly, I would have been wrong in any case because I tested this in SQL Server 2012 (since no version was specified I considered this valid):

    Both create scripts execute successfully and both stored procedure scripts fail when actually executed (obviously).

    I believe that you had copied & executed the script provided in the question. These scripts are referring to tables table1 & table2. To test the scripts you should first create the table2 in your database (as the question specifies). Otherwise both table1 & table2 will not be existing in the database & both scripts will run successfully.


    Sujeet Singh