Names of the collumns
Hello!
I need to make a query that returns the names of the collumns.
Could you help me?
Thank's Ronaldo
Hello!
I need to make a query that returns the names of the collumns.
Could you help me?
Thank's Ronaldo
use adventureworksdw I hope this is helpful.
select c.name
from syscolumns c
inner join sysobjects o
on c.id = o.id
where o.type = 'U'
and o.name = 'DimCustomer'
Vincent
Hi Vincent,
Your example will work in SQL Server 2000, but if you're using SQL Server 2005, it would be better to use the new catalog views instead of the old (and deprecated) system tables.
Here's the same query using the system catalog views. You'll notice that the two queries are very similar, so getting use to the new views should be fairly easy.
SELECT c.name
FROM sys.columns c
INNER JOIN sys.objects o
ON c.object_id = o.object_id
WHERE o.type = 'U' and o.name = 'TableName'
Regards,
Gail
I disgree, I would always sue the INFORMATION_SCHEMA as they are supposed not to change in future. So Your query should be something like this:
Select Column_Name
From INFORMATION_SCHEMA.Columns
Where OBJECTPROPERTY(OBJECT_ID(Table_name),'IsMSShipped') = 0
HTH, jens Suessmeyer.