SQL Recipes (Beta II)
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 Thread Tools Search this Thread Rate Thread
  #1 (permalink)  
Old 02-08-2007, 09: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!
Edit/Delete Message Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 02-09-2007, 05: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!
Edit/Delete Message Reply With Quote
  #3 (permalink)  
Old 03-01-2007, 11:19 PM
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!
Edit/Delete Message Reply With Quote
  #4 (permalink)  
Old 03-11-2007, 05: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!
Edit/Delete Message Reply With Quote
  #5 (permalink)  
Old 04-01-2007, 12: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!
Edit/Delete Message Reply With Quote
  #6 (permalink)  
Old 11-29-2007, 12: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!
Edit/Delete Message Reply With Quote
  #7 (permalink)  
Old 01-22-2008, 03: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
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may 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

Moderation Tools:



All times are GMT. The time now is 07:34 AM.


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

1 2 3 4 5 6 7