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 2000 Forums
 Transact-SQL (2000)
 Creating Column through T-SQL

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 FLAG
EMP001 8/17/09 1
EMP001 8/18/09 0
EMP002 8/17/09 0
EMP002 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.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-20 : 07:10:32
See Normalization Rules here
http://datamodel.org/NormalizationRules.html



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

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 Matrix

Daipayan
Go to Top of Page

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...

Go to Top of Page

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 )
Go to Top of Page

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 code

Madhivanan

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

- Advertisement -