SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Getting Table Definition
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vmurali
Yak Posting Veteran

India
88 Posts

Posted - 11/26/2006 :  04:32:23  Show Profile  Send vmurali a Yahoo! Message  Reply with Quote
Hi, Is there any way to get the table definition (Table columns, Table Columndatatype , Columndatasize). Can we get it using a single sql statement specifying database, table name.

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 11/26/2006 :  04:33:47  Show Profile  Visit SwePeso's Homepage  Reply with Quote
select * from information_schema.columns where table_name = '<your table name here>'


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vmurali
Yak Posting Veteran

India
88 Posts

Posted - 11/26/2006 :  04:41:56  Show Profile  Send vmurali a Yahoo! Message  Reply with Quote
Thanks for your reply. Will this work for if i have to get values from tables present in different databases. I have a source1 and source 2 database and I have to get details with respect to individual databases.

quote:
Originally posted by Peso

select * from information_schema.columns where table_name = '<your table name here>'


Peter Larsson
Helsingborg, Sweden

Go to Top of Page

harsh_athalye
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 11/26/2006 :  04:43:16  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
prefix information_schema with database name like this:

select * from db1.information_schema.columns where table_name = '<your table name here>'


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22761 Posts

Posted - 11/26/2006 :  23:49:58  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Other method is to use sp_help

Dbname..sp_help 'table name'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000