Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Computed Columns and Expressions

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-04-19 : 11:00:15
Chris R writes "I have exisitng production table (SQL Server 7.0) with several thousand records and I wish to add a computed column that computes the max value from a number of other columns in the same record.

I know MAX works on columns of data but can I use something similar for my computed column ?"

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-04-19 : 11:55:53
you may have to go down the route of something like the following....
and put the CASE statement into the definition of the COMPUTED column

select col1, case when (col2 > col3 and col2 > col4) then col2
when (col3 > col2 and col3 > col4) then col3
else col4
end
from tablename
Go to Top of Page
   

- Advertisement -