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
 Columns

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-05-26 : 10:29:26
Hi,

i have a table lets say dynamic and i wanna get the names of the columns. Is it possible with select?

thanks

sanjnep
Posting Yak Master

191 Posts

Posted - 2006-05-26 : 10:39:18
select name as [col name] from syscolumns where id = object_id('dynamic')

Sanjeev Shrestha
12/17/1963
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-05-26 : 11:04:54
or...

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'dynamic'

Ryan Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-05-26 : 11:21:49
or

Select top 0 * from dynamic

Srinika
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-26 : 11:29:38
quote:
Originally posted by Srinika

or

Select top 0 * from dynamic

Srinika



If you use variable that has table name that wont work without dynamic sql. Also it will have column headers with no data and will not column names

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-05-26 : 12:31:18
What's a dynamic table?

I know of virtual table, a derived table, a local temp table, a global temp table, your general run of the mill physical table, a table variable, but I have never heard of a dynamic table



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-27 : 02:24:13
quote:
Originally posted by X002548

What's a dynamic table?

I know of virtual table, a derived table, a local temp table, a global temp table, your general run of the mill physical table, a table variable, but I have never heard of a dynamic table



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



I think the questioner wants to pass table name as parameter

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -