create proc pc @a int, @b int, @c int output as select @c=max(c) from ( select @a as c union all select @b )
create proc pc @a int, @b int, @c int output as select @c=max(c) from ( select @a as c union all select @b ) tmp declare @a int, @b int, @c int select @a=10, @b=20 exec pc @a, @b, @c output select @c--result ----------- 20(1 row(s) affected)
select c=(case when a>b then a else b end)
as
select @c=max(c) from
(
select @a as c
union all
select @b
)
create proc pc @a int, @b int, @c int output
as
select @c=max(c) from
(
select @a as c
union all
select @b
) tmp
declare @a int, @b int, @c int
select @a=10, @b=20
exec pc @a, @b, @c output
select @c--result
-----------
20(1 row(s) affected)