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
Explain how many types of relationship?
How to specify the collation for a character data type in ms sql server?
Define left outer join?
Explain primary key?
What is the difference between indexing and hashing?
What's new in sql management studio for sql server? : sql server management studio
Do you know what are acid properties?
How to encrypt Strored Procedure in SQL SERVER?
What is report snapshot in ssrs?
why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it? : Sql server administration
What are the advantages of passing name-value pairs as parameters?
Can we perform backup restore operation on tempdb?
What options are there to delete rows on the publisher and not on the subscriber? : sql server replication
How to generate create procedure script on an existing stored procedure?
Explain what are the different index configurations a table can have?