Why I cannot use this?
declare @ln_x int
select @ln_x = x.col from ( select max(id) as col from table ) x
Server Message: Number 141, Severity 15
Server 'U00025_D', Line 2:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
but this works...
select x.col from ( select max(id) as col from table ) x
This example is trivial but I would like to use these constructions in my stored procedures...
e.g.
select .... from ( select ... from table ... ) a , table b, ( select ... from table ) c
where a.id = b.id
and c.id = b.id
and ...
or should I avoid these constlructions and use somthing else? Temporary tables (but if I am in transactions?)...