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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   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
How to Check Whether a Global Temporary Exists in a SQL 
Database or not?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How to Check Whether a Global Temporary Exists in a SQL Database or not?
Answer
# 1
Checking whether a table exists in a Microsoft SQL Server
database is easy. You can use this query: 

SELECT 'x'
FROM sysobjects
WHERE type = 'U' and NAME = 'mytable'
But this query will not work while searching for global
temporary tables. Global temporary tables are stored in tempdb. 
Use this syntax for the search: 

DECLARE @temp_table VARCHAR(100)
SET @temp_table = '##my_temp_table'
IF NOT EXISTS (SELECT 'x'
          FROM tempdb..sysobjects
          WHERE type = 'U' and NAME = @temp_table)
    PRINT 'temp table ' + @temp_table + ' does not exist'

ELSE
    PRINT 'temp table ' + @temp_table + ' exists.'
Note: You cannot search for local temporary tables (# prefix
tables) in this way. This is because SQL Server appends a
unique number to the name you supply. For example, if you
specified "#temp," the name in sysobjects would be something
like "#temp____1234." 
 
Is This Answer Correct ?    2 Yes 0 No
Guest
 
  Re: How to Check Whether a Global Temporary Exists in a SQL Database or not?
Answer
# 2
use tempdb

sp_tables '##%'
 
Is This Answer Correct ?    1 Yes 1 No
Ish
 
 
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
how to write the query to select the rows are in the order of either 1,3,5,7... or 2,4,6,8,... ADP5
what are file groups? Evalueserve3
can we call stored Procedure in Function in Sql Server 2000 and vice versa. eSoft2
Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan? HCL2
What is the difference between a HAVING CLAUSE and a WHERE CLAUSE? Yardi-Software4
what is meant by deafult in sql server?  2
what is the query and condition to delete datas in sql server.  2
What is the difference between IN and EXISTS operators in SQL Server? Intelligroup3
Explain some DBCC commands?  4
select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.  7
how to generate XML out of QUERY? McAfee1
How to delete particular value in the column of a table.Is it possible or not?if possible give it as in query.  4
How will u get 5 years back record?  4
Explain Active/Active and Active/Passive cluster configurations?  1
i want only duplicates rows from coloumn ex. emp_id(colomn name)1,1,2,3,3,4,5,5. so i want only duplicates no. iFlex2
I have a huge amount of data which is displayed in a report. The data is viewed every day. Every day the data is displayed in 30 secs but suddenly today it is giving an timeout message today. Data has not been changed. The situation is same as yesterday. What might be the reason??? Please Answer. Satyam4
What is a Linked Server?  1
how to delete duplicate rows from table CSC9
What is lock escalation?  1
What is Schema? and why we use schemas?  1
 
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