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 / soorai ganesh
Problem in #temp table. Because it comes twice in SP.
(U can say it is in else part. But compiler will not accept
this.First it will compile everthing then running the SP. )
Its better to keep another name for Else part table.......
Is This Answer Correct ? | 8 Yes | 6 No |
Post New Answer View All Answers
Write down the syntax and an example for create, rename and delete index?
Benefits of Stored Procedures?
What are entities and relationships?
What are the restrictions while creating batches in sql server?
Give a example to search fr a string in all stored procedure in sql server.
How to return the second 5 rows in ms sql server?
What is a data collection table?
What is the difference between deallocate cursor and close cursor?
what is denormalization? : Sql server database administration
Where is my database stored on the hard disk in ms sql server?
What is a derived table?
How to optimize stored procedures in sql server?
can an automatic recovery be initiated by a user? : Sql server administration
What is the difference in accessing db between sql server vs sql azure?
Why does sql studio use a single registered database repository? : sql server management studio