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 = 'city')

In this querry may name is Tablename
 
Is This Answer Correct ?    5 Yes 2 No
Kishore
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 2
select count (*) from tablename.
 
Is This Answer Correct ?    0 Yes 13 No
Ashutosh Jha
 
 
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 3
@Anshul..
Bro..through your code u can obtain the Total numbers of 
rows in your Table.
---------------------------------

For getting Total Columns i will use this:

SELECT Count(*)As Coloumns 
FROM Sys.SysColumns
Where ID = 
(SELECT ID FROM Sys.SysObjects Where Name = 'YourTableName')
 
Is This Answer Correct ?    3 Yes 1 No
Dharmendra K. Dixit
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 4
--Count of Columns
SELECT COUNT(*) NO_OF_COLUMNS
FROM SYS.COLUMNS
WHERE OBJECT_ID = OBJECT_ID('<TableName>')
ORDER BY Column_ID

--Column Names 
SELECT [NAME] 
FROM SYS.COLUMNS
WHERE OBJECT_ID = OBJECT_ID('<TableName>')
ORDER BY Column_ID
 
Is This Answer Correct ?    1 Yes 1 No
Anand K
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 5
IN SQLSERVER 20005 


SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = N'TABLENAME'


try in sql server 2000
 
Is This Answer Correct ?    6 Yes 1 No
Sudhir Kumar
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 6
None of the above answer can result the columns which is 
having auto incremented (Identity).
Also if a column is binded to user defined data type that 
is also  excluded....
So the Correct Number of column cannot be resulted in the 
above answers.........
 
Is This Answer Correct ?    0 Yes 2 No
Mohan
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
What is the difference between DTS and SSIS? Allianz1
can any one answer this query,thank you in advance Table 1 has 2 columns: EmployeeId, T shirtsize(values can be 1,2,3) Table 2 has 2 columns: EmployeeId, Region Write SQL to Find the region which has the largest number of people with Tshirt size=3 Google6
how to connect sybase to sql server 2005?. ABC1
How do you measure the performance of a stored procedure? Infosys1
what is extended StoreProcedure ? Satyam3
Hi Can any one tell me the Good institute to learn SQL esp for Data Base Testing or SQL from scratch to the proficiency level in Hyederabad and facult also. Thankyou well in advance  6
Display a roll having miminum marks in two subjects? Patni4
What is a cursor in SQL Server 2000 and their types?  2
What is the diff between Static Queries and Dynamic queries give me some examples CSC1
What is the diff between Dynamic queries and static queries ICS-Integrated-Computer-Solutions1
What is the difference between a local and a global variable?  2
How to select Distinct columns from the table, table having 20 columns and i want all coulmns Wipro2
What is the default value of CHAR type? Bosch6
How to determine the service pack currently installed on SQL Server? HCL2
is it possible to use a variable in a query with the IN clause (a,b,c..z), without getting quotes or conversion errors?  1
What are the different ways of moving data/databases between servers and databases in SQL Server?  1
what is the diffrence between Snap Shot and Transaction Replication CSC1
What are sub-queries? Give example? In which case sub-queries are not feasible? Infosys1
what are batch in sql server? Satyam2
What is a stored procedure?  3
 
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