• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic