create procedure proc1 (@a int)
as
begin
if @a=1
create table #temp(a1 int)
else
create table #temp(a1 int)
end

while executeing the above code it shows error
like '#temp already exist' .why it shows an error?

Answer Posted / murthy

The #Temp table created in this stores procedure exists in
memory as long as the Particular session is closed. Hence
drop the table at the end of the procedure.

Note: In case if you exec the SP using Management studio,
close the connection and re-open it, it will work without
modifying anything.

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What stored by the master? : sql server database administration

747


What is a document index?

770


hi, how to link a text file and a .rpt file in my tables of sql server and to retrieve those records for further use. reply me as soon as possible.

1740


Explain what is meant by replication of database?

720


Can we shrink data file in sql server?

758






Do you know what is a trace frag? Where do we use it?

716


What is sub-query in sql server?

879


Can one drop a column from a table?

752


How do I manually uninstall an instance of sql server 2016?

719


Explain trigger and its types?

797


What is a synonym for manipulation?

724


Which are the two editions in which SQL Azure database available?

115


What is sql server english query?

743


Write the syntax for stuff function in an sql server?

724


What do you mean by subquery?

746