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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 information_schema.columns

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2011-05-24 : 07:47:19
i run this
select * from information_schema.columns
where table_name = 'tableA'

i want to get

columnA,ColumnB instead 2 rows

columnA
columnB

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-05-24 : 07:49:31
use the for xml path method shown here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=81254


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-24 : 09:30:10
Or do like this;

declare @cols varchar(max) = ''
select @cols = @cols + column_name + ', ' from information_schema...
print @cols

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page
   

- Advertisement -