|   | ![]() |
|
The same holds true for the next
calculation. fkcolid = r.fkey1 * (1 -
abs(sign(p.Value - 1))) + r.fkey2 * (1 - abs(sign(p.Value - 2))) + r.fkey3 * (1 -
abs(sign(p.Value - 3))) + r.fkey4 * (1 - abs(sign(p.Value - 4))) + r.fkey5 * (1 - abs(sign(p.Value - 5))) + r.fkey6 * (1 - abs(sign(p.Value - 6))) + r.fkey7 * (1 - abs(sign(p.Value - 7))) + r.fkey8 * (1 - abs(sign(p.Value - 8))) + r.fkey9 * (1 - abs(sign(p.Value - 9))) + r.fkey10 * (1 - abs(sign(p.Value - 10))) + r.fkey11 * (1 - abs(sign(p.Value - 11))) + r.fkey12 * (1 - abs(sign(p.Value - 12))) + r.fkey13 * (1 - abs(sign(p.Value - 13))) + r.fkey14 * (1 - abs(sign(p.Value - 14))) + r.fkey15 * (1 - abs(sign(p.Value - 15))) + r.fkey16 * (1 - abs(sign(p.Value - 16))), will produce a set of 16 rows that look like the following:
The final calculation key_seq = 1 * (1 -
abs(sign(p.Value - 1))) + 2 * (1 - abs(sign(p.Value - 2))) + 3 * (1 - abs(sign(p.Value -
3))) + 4 * (1 - abs(sign(p.Value - 4))) +
It should be noted here that I could apply the calculations directly,
because the data in the fkey1...fkey16 and rkey1...rkey16 was numeric in origin
(smallint). If the data happened to be character in origin, then some additional
processing would have been required. |
All content on this site, except where noted, represents an original work of Michael R. Hotek and is protected by applicable copyright laws. The SQL Server FAQ is the sole work of Neil Pike. No page, portion of a page, or download may be used for commercial purposes in whole or in part without the express, written permission of the applicable author.