Add computed column using subquery

209 Views Asked by At

In SQL Server 2000, I want to add a computed column which basically is MAX(column1).

Of course I get an error because subqueries are not allowed.

What I basically try to do is to get the max(dateandtime) of a number of tables of my database.

However when I run my code it takes too long because it's a very old and badly designed database with no keys and indexes.

So, I believe that by adding a new computed column which is the max(datetime), I will do my query much much faster because I will query

(SELECT TOP 1 newcomputedcolumn FROM Mytable) 

and I will not have to do

(SELECT TOP 1 dateandtime FROM Mytable 
 ORDER BY dateandtime DESC)

or

(SELECT MAX(dateandtime) FROM Mytable)

which takes too long.

Any ideas? Thanks a lot.

0

There are 0 best solutions below