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

How do I start sql server?

604


What is the benefit of normalization?

687


What are the different authentication modes in sql server?

708


What is the maximum size of sql server database?

594


Where are SQL server users names and passwords are stored in sql server?

791






How do I delete a sql server database?

634


How to add the custom code in Report?

105


How to connect to a sql server using odbc_connect()?

714


What is table level trigger?

667


Where the sql logs gets stored? : sql server database administration

600


What are the differences between substr and charindex in sql server.

587


How do I view a stored procedure in sql server query?

606


What is the command used to recompile the stored procedure at run time?

701


Explain the different index configurations a table can have?

585


How to create an index on an existing table in ms sql server?

580