Connecting Tech Pros Worldwide Forums | Help | Site Map

constructing varchar computed column , using bit fields

Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#1: Nov 7 '07
Hi,
Due to a certain circumstance i have to add a field to my table, which would be a varchar type. this varchar contructs istfel using 4 fields of type bit

so if the table def goes as
isA(bit), isB(bit), isC(bit), isD(bit), ABCD(varchar(4))

the value of the field ABCD should be constructued from the 4 bit fields
if isA,isC is checked then ABCD should be AC
if isA,isB,isD is checked then ABCD should be ABD
is there a way i could achieve it using computed columns or would i have to make a trigger..(which i am also not sure on how to go about it)

Sorry for the trouble, but i couldnt get my head around with starting it either !

thankyou

Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#2: Nov 8 '07

re: constructing varchar computed column , using bit fields


Hi,
Updating on what i have done
Created a trigger on insert,update
and with a series of IF statements i contructed the varchar field based on if the bit fields were set to true.
Reply