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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
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 ?    0 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 ?    0 Yes 0 No
Ish
 
 
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
Alternative way to DetDate() function?  2
how to get the automatic backup of the database in the sql server  3
how to dispaly a particular row details from a given table  1
how can do you the system monitoring?  1
what is diffence between replicaion and logshipping?  1
I Have Employee table having column name as ID,SALARY how to get second max salary from employee table with id ex ID SALARY 1 20000 7 37000 2 5000  10
Can a stored procedure call another stored procedure. If yes what level and can it be controlled?  2
what are three different authentications to connect linked servers? CitiGroup1
Explain basic SQL queries with SELECT from where Order By, Group By-Having? Wipro1
Can I remove the default constraint columns in SQL SERVER? Value-Labs2
What is a Linked Server?  1
What are constraints? Explain different types of constraints?  5
how to implement locking in sql server Satyam1
What are sub-queries? Give example? In which case sub-queries are not feasible? Infosys1
What are the authentication modes in SQL Server?  2
What is ACID Property of Transaction?  3
WHY CAN WE CREATE ONLY ONE CLUSTERED INDEX ON A TABLE IN SQL SERVER?  5
Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?  2
How to write stored procedure to update the data in 10 tables  3
What does the INSTEAD OF trigger do?  2
 
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