>I was trying this one:
>
ALTER TABLE MyTable ADD PRIMARY KEY Field1 + Field2 + Field3 tag pk>but I get....
Operator/operand type mismatch. Field2 is char, but that's not would be trouble, well, I think.
>
>Sorry by my ignorance, if I have this records...
>Field1 Field2 Field3
>----------------------------
>4 5 1
>3 1 6
>
>it will be a duplicate key? (i.e. 4+5+1=10 and 3+1+6=10 too!!!)
>
>
>Thanks a lot!!!
All fields being concatenated must be of the same type or be able to be converted to the same type. Also, you can not, or better put should not, concatenate integer/numeric expressions, for the reason you gave.
In order to concatenate your keys, you should convert them to character. You should also pad them with some expression so that values with different lengths (e.g. 5 and 10) do not step on each other when converted. Ex.
ALTER TABLE MyTable ADD PRIMARY KEY padl(Field1,5,'0') + Field2 + padl(Field3,5,'0') tag pk
The above works if Field1 and Field3 are integers and Field2 is a character. If all are numeric/integer, use PADL on all of them.
HTH.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao