November 1, 2006 at 4:12 am
Hi all,
I want result in one select of following table as below:
RowID Message MessageType
1 To ‘some name’
2 From ‘My Name’
3 To ‘some other name’
4 Cc ‘some CC name’
5 BCC ‘some BCC Name’
6 UserBCC ‘some UserBCC name’
Results should be as:
To From CC BCC UserBCC
some name; some other name’ My Name some CC name’ some BCC name’ some UserBCC name’
I know well I can do this via stored procedure, but I think it can be some using Pivot features of SQL Server 2005. Plz help me solving this as soon as possible.
Thanks in advance.
Shamshad Ali
November 1, 2006 at 2:06 pm
You are making a big mistake. Using an Entity/Attribute (MUCK) table for this is going to cause you no end to grief.
Why not have a Message table and then have a many to many relationship between it and a From table, a To table and a CC table?
Any time you start needing to do crosstab queries you ought to stop and think long and hard before proceeding. This is fundamentally a presentation issue and belongs in the application, while maintaining data integrity is a database issue, which is made impossible by the use of a MUCK table.
/*****************
If most people are not willing to see the difficulty, this is mainly because, consciously or unconsciously, they assume that it will be they who will settle these questions for the others, and because they are convinced of their own capacity to do this. -Friedrich August von Hayek
*****************/
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply