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)
 Making ROWS to be acts as another tables' Columns

Author  Topic 

ammarfassy
Starting Member

1 Post

Posted - 2009-12-01 : 11:18:50
Dear ALL,

I have a table named FIELDS with field names (ID, FieldName)

with the data is as follow :

ID FieldName
1 FullName
2 Address
3 City
4 Country

I need to display these values in column wise.

for ex :

FullName Address City Country
Ravi aaaaa aaa aa
Andy bbbbb bbb bb
Apollo ccccc ccc cc

thanks in advance,

Ammar.

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2009-12-02 : 11:34:41
Hi Ammar

There's a query at the end of this article that shows you how to query tables like this.

[url]http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistakes.html[/url]

Note that the article is called 'OTLT and EAV: the two big design mistakes all beginners make', and I recommend you read the whole lot and consider whether your current design is really what you want before you start writing too many queries against it.


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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-03 : 03:25:48
This may involve in dynamic sql
Make sure you read this fully
www.sommarskog.se/dynamic_sql.html

Madhivanan

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

- Advertisement -