SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack (1) Thread Tools Search this Thread
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 02-08-2007, 10:24 PM
Nicolas Fournier
 
Posts: n/a
Default SQL 92 dialect question:

How to get table structure via SQL?


Hi, I'm currently programming an automatic class builder that will create C# or VB class to controll a SQL Server 2000 data base. I need to be able to select the structure of the table to extract the Column names, types, max length, etc. I've done this while I was in college, but I don't seems to find any clue about it on Inet. Any idea ?

Select Struct ???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 02-09-2007, 06:47 AM
Dimitar
 
Posts: n/a
Default MS SQL answer. Re: How to get table structure via SQL?

http://www.simple-talk.com/dotnet/.net-framework/schema-and-metadata-retrieval-using-ado.net/
Does this help?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-02-2007, 12:19 AM
Avaneesh
 
Posts: n/a
Default MS SQL answer. Re: How to get table structure via SQL?

SELECT table_name,ordinal_position,column_name,data_type,  is_nullable,character_maximum_length FROM
information_schema.COLUMNS WHERE table_name LIKE '%TABLENAME%'
ORDER BY ordinal_position
[b]AVANEESH[b]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-11-2007, 06:11 PM
meera
 
Posts: n/a
Default MySQL answer. Re: How to get table structure via SQL?

DESCRIBE ;
or
SELECT column_name,column_type,is_nullable,column_key,col  umn_default,extra FROM information_schema.COLUMNS WHERE
table_schema='' AND table_name=''
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-01-2007, 01:52 PM
amar
 
Posts: n/a
Default MS SQL answer. Re: How to get table structure via SQL?

sp_help 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-29-2007, 01:04 PM
vishwanath
 
Posts: n/a
Default ANY answer. Re: How to get table structure via SQL?

In SQL server

We can use this statement to get the structure of a table

EXEC sp_help <table_name>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-22-2008, 04:16 AM
lavanya lavanya is offline
Junior Member
 
Join Date: Jan 2008
Posts: 2
lavanya is on a distinguished road
Cool ANY answer. Re: How to get table structure via SQL?

Go to Sql server 2000 and execute " sp_help tablename" i already worked with it.it definitely works.
__________________
lavanya kunala


lavanya.kunala@gmail.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-20-2008, 05:24 AM
Unregistered
 
Posts: n/a
Default ANY answer. Re: How to get table structure via SQL?

Quote:
Originally Posted by Avaneesh View Post
SELECT table_name,ordinal_position,column_name,data_type,  is_nullable,character_maximum_length FROM
information_schema.COLUMNS WHERE table_name LIKE '%TABLENAME%'
ORDER BY ordinal_position
[b]AVANEESH[b]
Thanks a lot for this...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.sqlrecipes.com/sql_questions_answers/how_get_table_structure_via_sql-92/
Posted By For Type Date
superbullet's bookmarks on del.icio.us This thread Refback 05-16-2008 02:04 PM


All times are GMT. The time now is 08:04 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8