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 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 ?    17 Yes 4 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 ?    1 Yes 35 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 ?    10 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 ?    5 Yes 3 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 ?    15 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 ?    1 Yes 3 No
Mohan
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 7
select count(*) from syscolumns where id=(select id from
Sysobjects where [name]='Table_Name')
 
Is This Answer Correct ?    1 Yes 1 No
Bhaskar
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 8
select count(column_Name) from information_schema.columns 
where table_name='tableName'
 
Is This Answer Correct ?    1 Yes 0 No
Saravanan P
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 9
Guys.. Why don;t you try for the Columns bided with User 
Defined Data Type and try the above queries... and Also try 
for the Auto incremented Columns..(Identity)....
Your opinion would  change definately....
Try out...
I am sure it doesn't take account of UDT Binded Coulmns
 
Is This Answer Correct ?    0 Yes 0 No
Mohan
 
  Re: how to find number of columns in a table in sql server 2000 and 2005 also
Answer
# 10
SELECT Count(*)As Coloumns 
FROM SysColumns
Where ID = 
(SELECT ID FROM SysObjects Where Name = 'TableName')
 
Is This Answer Correct ?    0 Yes 0 No
Vidit Tyagi
 

 
 
 
Other SQL Server Interview Questions
 
  Question Asked @ Answers
 
can foreign key take role of primary key? TCS4
What is the difference between login and a user? TCS7
can you any body tell me suppose database is suspect mode. how can take to normal? Teledata1
what is replication? where do u use Go Keyword? Satyam1
How do you use DBCC statements to monitor various aspects of a SQL server installation?  1
How do you know which index a table is using?  4
How to handle errors in Stored Procedures. I want to display a message to the user in the .aspx page that is calling a stored procedure in it's code behind. please help me. 247Customer1
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 is Deadlock? Satyam3
How can u convert the Date to String? TCS4
difference between sql server2000 and sql server2005 KPMG1
hi, i have a table called names and field name select * from names name a b c d i want to display like this name a,b,c,d how it is possible Regards Baiju  3
What is the difference between IN and EXISTS operators in SQL Server? Intelligroup3
can we call functions from stored procedure in SQL Server 2005 ? How?  2
Can you link only other SQL Servers or any database servers such as Oracle?  1
what is Constraint? How many types of constraints in SQL ? NIIT7
What is the difference between Stored Procedure , Function and Package, 1. how many blocks in Package and what are they. IBM5
how insert selected column only ? Robert-Half2
Which is the subset of SQL commands used to manipulate Oracle Database structures, including tables?  2
What is data integrity? Explain constraints? Thinksoft1
 
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