TSQL allocate variables from child result set to avoid repeating query

Is there a way to efficiently improve on the code below without repeating the query like this?

Note: There is a known number of elements for assigning arguments to in this case.

SELECT  @var0 = Field_A FROM Table_0 
JOIN Table_1 ON (Table_0.PK = Table_1.FK) 
WHERE Table_1.PK = 1 AND TABLE_0.Field_B = 1;

SELECT  @var1 = Field_A FROM Table_0 
JOIN Table_1 ON (Table_0.PK = Table_1.FK) 
WHERE Table_1.PK = 1 AND TABLE_0.Field_B = 2;

SELECT  @var2 = Field_A FROM Table_0 
JOIN Table_1 ON (Table_0.PK = Table_1.FK) 
WHERE Table_1.PK = 1 AND TABLE_0.Field_B = 3;

Answers


Something like this:

SELECT
    @var0 = MAX( CASE table_0.field_b WHEN 1 THEN field_a END )
    , @var1 =   MAX( CASE table_0.field_b WHEN 2 THEN field_a END )
    , @var2 =   MAX( CASE table_0.field_b WHEN 3 THEN field_a END )
FROM 
    table_0
JOIN
    table_1 
    ON 
        TABLE_0.PK = TABLE_1.FK

Need Your Help