In SQL Server 2005, when I write a query like
SELECT m.*, a.price p1, b.price p2
FROM mytable m
LEFT JOIN products_table_1 a
ON my_hash_function(m.name) = a.hash
LEFT JOIN products_table_2 b
ON my_hash_function(m.name) = b.hash
is my_hash_function(m.name)
calculated twice or just once? If twice, how can I use a variable to avoid that?