This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to view the Datatypes of the Columns of a Table in SQLSERVER