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


Please Help Members By Posting Answers For Below Questions

How do I create a stored procedure in dbml?

687


What is partition index in sql server?

798


What is the sql server 2000 version number?

771


How many types of triggers in sql server?

711


How to connect sql server management studio express to sql server 2005 express?

747






Explain what are magic tables in sql server?

699


What is sql server management studio? : sql server management studio

738


How to convert numeric expression data types by assignment operations?

723


explain different types of cursors? : Sql server database administration

751


How to delete exactly duplicate records from a table?

803


Can primary key be a foreign key?

759


what is an index? : Sql server database administration

680


What is sub-query in sql server?

879


What are the different kinds of ssrs reports?

192


What is cte (common table expression)?

769