• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

How to create a temp table.

I tried

INSERT INTO #temptable
EXEC sp_Who2

but get error

Msg 208, Level 16, State 0, Line 1
Invalid object name '#temptable'.
0
turbot_yu
Asked:
turbot_yu
  • 3
2 Solutions
 
Eugene ZCommented:
--try:
--drop table #temptable
create table #temptable
(
id  SMALLINT,
status  CHAR(30) ,
login  CHAR(128) ,
hostname CHAR(128),
blkby  CHAR(5) ,
dbname  CHAR(128) ,
command  CHAR(16) ,
cputime  INTEGER ,
diskiO  INTEGER ,
lastbatch  varchar(1000) ,
programname CHAR(128) ,
spid1  SMALLINT )



insert into #temptable
exec sp_who2

 select * from #temptable

0
 
HuyBDCommented:
EXEC sp_Who2 INTO #temptable
0
 
HuyBDCommented:
Sorry, I have wrong answer
0
 
turbot_yuAuthor Commented:
EXEC sp_Who2 INTO #tmptable

Msg 10054, Level 20, State 0, Line 0
A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)
0
 
HuyBDCommented:
turbot_yu, thank for your point!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now