Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    188

    Unanswered: Invalid Object Name #IDResults

    disregard type on sql syntax
    Last edited by jo15765; 11-12-13 at 14:22. Reason: error

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    It looks to me that you are recreating the temp table with each loop iteration. For now dump the SELECT... INTO..., create the temp table before the loop and do an INSERT INTO in the loop.

    Down the road you ought to learn why procedural and loop based logic is not good in SQL and you should learn about set based processing.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Feb 2012
    Posts
    188
    Quote Originally Posted by Thrasymachus View Post
    It looks to me that you are recreating the temp table with each loop iteration. For now dump the SELECT... INTO..., create the temp table before the loop and do an INSERT INTO in the loop.

    Down the road you ought to learn why procedural and loop based logic is not good in SQL and you should learn about set based processing.
    Well my friend you are correct on that. I googled (after your post) and saw what poor SQL it is to do that. Surprisingly I was copying an example from our Senior SQL Developer who did it that way initially.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •