I have a table (result of a stored procedure from someone else), and it retuns a table ##tableT in the form
1 2 3 4 5 6
----------------------------------------------
467 116 480 477 491 697
NULL 19 481 113 488 466
123 4354 477 466 55 480
NULL NULL NULL 527 83 629
45 34 NULL 5 483 483
As you can see it has NULLS, and most important the name of the columns are numbers, so when I do
SELECT coalesce(1, -1) as att1, coalesce(2, -1) as att2,....,coalesce(6, -1) as att6 FROM [dbm].[dbo].[##tableT];
I get:
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6
Instead of:
1 2 3 4 5 6
----------------------------------------------
467 116 480 477 491 697
-1 19 481 113 488 466
123 4354 477 466 55 480
-1 -1 -1 527 83 629
45 34 -1 5 483 483
try