File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to view the Datatypes of the Columns of a Table in SQLSERVER Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to view the Datatypes of the Columns of a Table in SQLSERVER" Watch "How to view the Datatypes of the Columns of a Table in SQLSERVER" New topic
Author

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

Ramesh Shanmugam
Ranch Hand

Joined: Sep 13, 2004
Posts: 132
I have a table called student in sqlserver.How to view the Datatypes of the Columns of the Table in SQLSERVER2000


Ramesh Shanmugam - SCJP 1.5
Jyothi Lature
Ranch Hand

Joined: Oct 31, 2001
Posts: 60
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.


Jyothi<br />Sun Certified Java Programmer<br />Brainbench Certified for Javascript
Prashant Jain
Greenhorn

Joined: Aug 19, 2004
Posts: 29
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
 
Consider Paul's rocket mass heater.
 
subject: How to view the Datatypes of the Columns of a Table in SQLSERVER
 
Similar Threads
help needed for this query...
Screen resolution
A few Good questions..
JTable cells way to big !!!
JTable-Getting Data out to db