Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 is there better way to do this?

Author  Topic 

mind_grapes
Yak Posting Veteran

71 Posts

Posted - 2009-08-25 : 07:08:18

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 - 2009-08-25 : 07:10:59
select * from information_schema.columns where table_name = 'x'
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

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

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-08-25 : 07:13:56
[code]
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
[/code]



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

mind_grapes
Yak Posting Veteran

71 Posts

Posted - 2009-08-25 : 07:18:45
Thanks guys, has worked.

Regards
MG
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-08-25 : 07:19:56
welcome
Go to Top of Page
   

- Advertisement -