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.
Author |
Topic |
daipayan
Posting Yak Master
181 Posts |
Posted - 2009-08-20 : 01:37:35
|
Is there any possibility to create columns through TRIGGER?I mean to say, if I have table name employee_register where column will be generated in the following way:-----------------------------------------------------EMPCODE | 8/17/2009 | 8/18/2009 | 8/19/2009 | .....-----------------------------------------------------EMP001 | 1 | 0 | <NULL> | .....EMP002 | 0 | 0 | <NULL> | .....EMP003 | <NULL> | <NULL> | <NULL> | ........----------------------------------------------------- Daipayan |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2009-08-20 : 06:48:59
|
You absolutely DO NOT want to do this. Store your data like so:EMPCODE DATEVALUE FLAGEMP001 8/17/09 1EMP001 8/18/09 0EMP002 8/17/09 0EMP002 8/18/09 0...etc. Then write a query using the PIVOT operator to do the cross-tabulation. Or better yet, do the cross-tab in a report, like a Reporting Services matrix. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
daipayan
Posting Yak Master
181 Posts |
Posted - 2009-08-21 : 09:16:21
|
I know about normalisation, but I do not enough knowledge about this Reporting Services MatrixDaipayan |
|
|
shzkhan28
Starting Member
15 Posts |
Posted - 2009-08-25 : 23:13:54
|
Hi robvolk,Could you give some examples for query using the PIVOT operator to do the cross-tabulation.Thanks... |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-08-27 : 00:20:06
|
HI, i think it is not pivot, it is unpivot ( to change the values row wise to column wise ) |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-27 : 02:11:54
|
quote: Originally posted by shzkhan28 Hi robvolk,Could you give some examples for query using the PIVOT operator to do the cross-tabulation.Thanks...
Refer SQL Server help file. It has example codeMadhivananFailing to plan is Planning to fail |
|
|
|
|
|