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 find number of columns in a table in sql server 2000
and 2005 also
 Question Submitted By :: Ramesh
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 1
SELECT count(*) NoOfColumns FROM SYSCOLUMNS
WHERE id= (Select id from SYSOBJECTS where name = 'TableName')
 
Is This Answer Correct ?    2 Yes 1 No
Jerry Joseph
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 2
--FOR Given Table Name.
SELECT COUNT(*) FROM SYS.COLUMNS
WHERE ID = OBJECT_ID('<TABLENAME>')

--For All UD Tables in the current DB
SELECT OBJ.NAME,COUNT(*) 
FROM SYS.COLUMNS COL,SYS.OBJECTS OBJ
WHERE OBJ.OBJECT_iD = COL.OBJECT_ID
AND TYPE = 'U'
GROUP BY OBJ.NAME
 
Is This Answer Correct ?    0 Yes 0 No
Anand K
 
 
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 3
Select Count(Column_Name) As NoOfColumns From 
Information_Schema.Columns Where table_Name='Company'
 
Is This Answer Correct ?    2 Yes 0 No
Kumar.t
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 4
SELECT count(*) NoOfColumns FROM SYSCOLUMNS
WHERE id= (Select id from SYSOBJECTS where name 
= 'TableName')
 
Is This Answer Correct ?    1 Yes 0 No
Amit
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 5
SELECT DISTINCT SYS.NAME,COUNT(*) FROM SYSOBJECTS SYS
INNER JOIN SYSCOLUMNS SYSCOL ON SYSCOL.ID=SYS.ID
WHERE SYS.XTYPE='U' GROUP BY SYS.NAME
 
Is This Answer Correct ?    0 Yes 0 No
Sujitha
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 6
sp_help tablename

  another command is

     select name from syscolumns where id=object_id
('table_name')
 
Is This Answer Correct ?    1 Yes 1 No
Naren
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
In performance wise distinct is good or group by is good? eg:select name from emp group by name; select distinct name from emp; Infosys2
What is transaction ? Give me one example. Melstar7
How many index keys possible for a table  6
What are the steps you will take to improve performance of a poor performing query? HCL1
hi i gone though satyam interview. what is Acid Properties? Satyam2
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
What command do we use to rename a db?  3
What is an extended stored procedure? Can you instantiate a COM object by using T-SQL? HCL3
There is a trigger defined for INSERT operations on a table, in an OLTP system. The trigger is written to instantiate a COM object and pass the newly insterted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? HCL1
What does it mean to have quoted_identifier on? What are the implications of having it off?  1
What are the types of backup and tell me the difference between full and differential backup? TCS3
What are primary keys and foreign keys?  3
How to link up the text file to a Database table? Allianz1
How to write stored procedure to update the data in 10 tables  3
wat will be the sql query to extract only last 3 records from table supose table hving thousands for records  14
What is a trigger?  3
What are user defined datatypes and when you should go for them?  1
What are the steps you will take, if you are tasked with securing an SQL Server? HCL1
Which system tables contain information on privileges granted and privileges obtained  1
Let us say the SQL Server crashed and you are rebuilding the databases including the master database what procedure to you follow?  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