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 / lee

yep problem is with the compiler.. I had to think of
another way to solve the problem, eg, I created the #temp
without the IF statement and then used an IF ELSE statement
to modify or update #temp, make sense?

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does recursive cte works in sql server?

524


Give me a SQL Query to find out the second largest company?

688


What are user-defined functions (udfs) in sql server?

570


What is snapshot report?

129


What are the tools available in market as an alternative to sql server reporting services?

88






What is named calculation? : sql server analysis services, ssas

529


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

528


How can you find out if the current user is a member of the specified microsoft® windows nt® group or microsoft sql server™ role?

596


What is the use of @@spid?

570


What is user-defined scalar function?

553


Do I need a report server to run reports in my application?

106


What are the difference between data mart and data warehouse? : sql server analysis services, ssas

500


What is the default sql server instance name?

558


What is difference between equi join and natural join?

535


What are audit control procedures?

582