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 / saravanan p

Since the stored procedure precompiled, we cannot give same
table name in both the If and else part.

It will work if give some other name in else part.

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is attribute? : sql server analysis services, ssas

583


What are the advantages of using third-party tools?

547


Explain powershell included in sql server 2008?

609


What is it unwise to create wide clustered index keys?

581


what is raid and what are different types of raid configurations? : Sql server database administration

536






How sql server executes a statement with nested subqueries?

507


is it important for a database administrator to understand the operating system and file access? : Sql server administration

583


What are views in ms sql server?

594


It is important form e to get the information from log files of applications executed by the task scheduler? Does sql studio save these log files? : sql server management studio

551


How to use subqueries in the from clause in ms sql server?

563


Hi, I Created 3 Tables Person(PersID[prkey],Name,Email,Password), Project(ProjName,ProjID[prkey],ProjLeader,ProjManager) & ProjectInvolvement(EntryDate,ProjID[frkey],PersID[frkey],ProjDuration). For this how can i INSERT,UPDATE & DELETE Through PROCEDURE? Please Post the Answer for me. Desai.

1425


How to delete duplicate rows from table except one?

543


How to use transact-sql statements to access the database engine?

537


Explain how to use linked server?

563


what is normalization? : Sql server database administration

529