With the idea of teaching a person to fish, a temp table is still a table and you're trying to create one in each of the 3 procs. That's the hint you need to find the MS documentation on the subject. So, do a search for the following...
CREATE TABLE (Transact-SQL)
The first item returned in the search will probably be the MS documentation on the subject. If it's not, it probably won't be far from the top.
Once found, click on the link to get to the MS article (documentation) on the subject. It's a pretty long article so press [Ctrl][F] to do a find in the browser and search for "Temporary Table" (without the quotes) and click whatever your browser recognizes for the "next" instance of what it found until you get to the section about temporary tables. The information you seek, along with a whole lot more about temporary tables, is there.
For your cursor question, do similar.
Make sure that you read about the differences between "local" and "global" versions of the objects in each of the two articles because the answer to both of your questions actually is "It Depends". 😉
is pronounced "ree-bar
" and is a "Modenism
" for R
First step towards the paradigm shift of writing Set Based code:
________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
"Change is inevitable... change for the better is not".
"Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"
How to post code problems
How to Post Performance Problems
Create a Tally Function (fnTally)