Is it possible to do something similar to the following:
I've also tried something like this:
But SQL Server doesn't like my use of the INTO clause. I would like to get back one record with the definitive max.
Code:
SELECT Max(id) FROM
(
SELECT Max(id) FROM table1
UNION
SELECT Max(id) FROM table2
)
I've also tried something like this:
Code:
SELECT Max(id) FROM table1 INTO @inttest1
SELECT Max(id) FROM table2 INTO @inttest2
If @inttest1 > @inttest2
Begin
@intmaxpk = @inttest1
End
Else
Begin
@intmaxpk = @inttest2
End
SELECT @intmaxpk
But SQL Server doesn't like my use of the INTO clause. I would like to get back one record with the definitive max.