Temp Tables and Table Variables

  • Yup, sorry I refreshed my browser and did not notice your reply on the second page.

    As for the request to post the "original" code, that would not have helped given that was where I made the original mistake, which then just got copied over to the cut-down version.

    Thanks to all for your help

  • ....but why was the error message pointing to the wrong line in the code....

  • Sorry Remi, what I did was try and isolate the problem and provide the key element that was failing. The actual line that contained the error - as posted in my messages - was

    a) in my initial post:

    /* Retrieve distinct Course count */

    SELECT @CourseCount = COUNT(DISTINCT(Course_ID) FROM #EventOpsList2

    b) in my sample script

    /* Retrieve distinct Course count - BOTH STMTS BELOW GIVE THE SAME ERROR MSG*/

    --SELECT @CourseCount = COUNT(DISTINCT(Course_ID) FROM @EventOpsList

    --SELECT @CourseCount = COUNT(DISTINCT(Course_ID) FROM #EventOpsList2

    c) in the original code

    /* Retrieve distinct Course count */

    SELECT @CourseCount = COUNT(DISTINCT(Course_ID) FROM #EventOpsList2

    As far as I can tell I did not alter the erroneous code, so what is the point you are trying to make?

    I also am not ranting, but I did not simply post some hacked together code. I prepared sample scripts which I ran and tested to make sure they reproduced the problem before submitting them.

  • You're right, I should have executed the original code, I'd have seen the error right away. Next time I'll try to ignore those messages :

    SELECT A.Event_ID, A.Course_ID

    FROM dbo.Event A --***** THIS IS THE LINE THE ERROR MSG REFERS TO ??? *****

    I didn't read the rest of the proc because I assumed that the error was there.

    Next time you get an error, rerun the script in QA, then double-click on the error, it'll bring you to the correct line of code directly. There won't be any errors in the place of the error that way.

  • Good thing that you keep agreeing with me!


    * Noel

  • OK, you're even more right. I did not double click on the line which would at least have highlighted where the error actually was.

    Thanks again for the time taken.

  • NP... at least we all learned something here .

  • Can't disagree when I'm wrong and you're right .

Viewing 8 posts - 16 through 22 (of 22 total)

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