How to create a temporaray table every time when the procedure is called.

The procedure should check whether the table is existing, if it exists it should
How to create a temporary table every time when the procedure is called,
The table should get deleted first and then recreated every time
searchsanjaysharmaAsked:
Who is Participating?
 
rajvjaCommented:
if object_id (N'tempdb..#tablename', N'U') is not null
            drop table #tablename;

create #tablename ()
0
 
Bhavesh ShahLead AnalysistCommented:
Hi,

you no need to explicitly drop the temporary table in procedure.
temp Table itself get dropped after completion of execution of procedure.
0
 
searchsanjaysharmaAuthor Commented:
thanx
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.

All Courses

From novice to tech pro — start learning today.