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
 General SQL Server Forums
 New to SQL Server Programming
 is there better way to do this?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mind_grapes
Yak Posting Veteran

71 Posts

Posted - 08/25/2009 :  07:08:18  Show Profile  Reply with Quote

Hi all quick quesiton. Is this the most effiecient way to do this? I want to display all columns in MS SQL:

select
syscolumns.name as [Column],
syscolumns.xusertype as [Type],
sysobjects.xtype as [Objtype]
from
sysobjects, syscolumns
where sysobjects.id = syscolumns.id
and sysobjects.xtype = 'u'
and sysobjects.name = 'tblAssociation'
order by syscolumns.name

raky
Aged Yak Warrior

767 Posts

Posted - 08/25/2009 :  07:10:59  Show Profile  Reply with Quote
select * from information_schema.columns where table_name = 'x'
Go to Top of Page

bklr
Flowing Fount of Yak Knowledge

India
1693 Posts

Posted - 08/25/2009 :  07:12:18  Show Profile  Reply with Quote
select * from information_schema.columns where table_name = 'tblAssociation'
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 08/25/2009 :  07:13:56  Show Profile  Send rajdaksha a Yahoo! Message  Reply with Quote

SELECT   sysobjects.name   AS table_name ,
         syscolumns.name   AS column_name,
         systypes.name     AS datatype   ,
         syscolumns.LENGTH AS LENGTH
FROM     sysobjects
         INNER JOIN syscolumns
         ON       sysobjects.id = syscolumns.id
         INNER JOIN systypes
         ON       syscolumns.xtype = systypes.xtype
WHERE (
                  sysobjects.xtype = 'U'
         )
ORDER BY sysobjects.name,
         syscolumns.colid




-------------------------
R...
Go to Top of Page

mind_grapes
Yak Posting Veteran

71 Posts

Posted - 08/25/2009 :  07:18:45  Show Profile  Reply with Quote
Thanks guys, has worked.

Regards
MG
Go to Top of Page

bklr
Flowing Fount of Yak Knowledge

India
1693 Posts

Posted - 08/25/2009 :  07:19:56  Show Profile  Reply with Quote
welcome
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.12 seconds. Powered By: Snitz Forums 2000