ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Databases  >>  SQL Server
 
 


 

 
 Oracle interview questions  Oracle Interview Questions
 SQL Server interview questions  SQL Server Interview Questions
 MS Access interview questions  MS Access Interview Questions
 MySQL interview questions  MySQL Interview Questions
 Postgre interview questions  Postgre Interview Questions
 Sybase interview questions  Sybase Interview Questions
 DB Architecture interview questions  DB Architecture Interview Questions
 DB Administration interview questions  DB Administration Interview Questions
 DB Development interview questions  DB Development Interview Questions
 SQL PLSQL interview questions  SQL PLSQL Interview Questions
 Databases AllOther interview questions  Databases AllOther Interview Questions
Question
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?
 Question Submitted By :: Sudheermuvva
I also faced this Question!!     Rank Answer Posted By  
 
  Re: 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
# 1
Because, Stored procedure is pre-compiled language.
 
Is This Answer Correct ?    2 Yes 9 No
Utpal Chakraboarty
 
  Re: 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
# 2
Because temp is being used by database internally so that it
is same as a system table so this table can't create by user...
 
Is This Answer Correct ?    0 Yes 9 No
Gaurav
 
 
 
  Re: 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
# 3
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 ?    4 Yes 3 No
Soorai Ganesh
 
  Re: 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
# 4
it indicates that some one had already executed the stored 
proc but forgotten to delete the temp table they have 
created.

normally before closing that particular transaction within 
the SP we need to use drop table statement.
 
Is This Answer Correct ?    1 Yes 3 No
David
 
  Re: 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
# 5
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 ?    1 Yes 0 No
Saravanan P
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
what are batch in sql server? Satyam2
As a part of your job, what are the DBCC commands that you commonly use for database maintenance? HCL1
hi, may i know what is the command to get abstract the current month, current year and current day from a given date.i want these three in a isolated way..seperatedly is that any way in sql server 2000  3
Explain Active/Active and Active/Passive cluster configurations?  1
hi i gone though satyam interview. what is Acid Properties? Satyam2
how many types of store procedre in sqlserver 2000? ATI2
What is a trigger?  6
wht is normalization?can u explain me in detail? TCS6
What is a Lock and let me know Different types of locks?  1
What does it mean to have quoted_identifier on? What are the implications of having it off?  2
How to select Distinct columns from the table, table having 20 columns and i want all coulmns Wipro3
How can we write or define DDL statements in Sql server and DML statements?  2
MULTICAST DELEGATES IN C#.NET WITH REAL TIME EXAMPLE IBM1
What are the types of backup and tell me the difference between full and differential backup? TCS3
How many types of cursors are there in SQL Server? 247Customer3
What is the order in which the SQL query is executed? list them in order. CTS1
hi, how to match retrieve the unmatched records from 2 tables in which we dont have any primary key. example : table1 has 1,2,3,4,5 and table2 has 1,2,3,4,5,6,7,8,9,10 and i want the numbers from 6 to 10 to be displayed and should not come as null. i need the numbers. please reply as soon as possible.  2
What is Query Execution Plan? How does it help optimize or tune a database driven application? Accenture2
What's the maximum size of a row?  4
What is an index? Yardi-Software7
 
For more SQL Server Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com