Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to view the Datatypes of the Columns of a Table in SQLSERVER

 
Ramesh Shanmugam
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table called student in sqlserver.How to view the Datatypes of the Columns of the Table in SQLSERVER2000
 
Jyothi Lature
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If the question is regarding SQLServer 2000 database particularly, then i think this is a wrong place to post this question. If it is regarding JDBC, then the solution would be to use ResultSetMetaData Interface.
The sample code to get the column Data type would be:

ResultSet rs = st.executeQuery("Select * from student");

ResultSetMetaData rsmd = rs.getMetaData();
String col_dtype = rsmd.getColumnTypeName(1);

Variable col_dtype will have the column data type for the first column of student table.
Similarly, you can put the last line in a loop to get the column datatype for all columns.
 
Prashant Jain
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jyothi is write about this question being in a different section.
However

sp_help Students

should let you do what you are trying to.


Prashant Jain
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic