November 18, 2003 at 2:14 am
I am trying to think of a way of adding the contents of certain numeric colmuns (about 7) and updating the results in another column
However I want to do it more elegantly than
Set Column8 = Column2 plus Column3 plus Column4 etc
November 18, 2003 at 2:22 am
What's wrong with this way?
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
November 18, 2003 at 2:50 am
Maybe try a computed column?
Tim Wilkinson
"If it doesn't work in practice, you're using the wrong theory"
- Immanuel Kant
November 18, 2003 at 3:13 am
OK, how do I do a computed column
November 18, 2003 at 3:31 am
You can create a computed column in a create or alter table statement.
E.g.
(Replace the word plus with a plus sign - its not showing when I preview )
create table MY_TABLE
(
COL1 int,
COL2 int,
COL3 varchar(25),
COL4_COMPUTED as col1 plus col2
)
OR
alter table MY_TABLE
add MY_COMPUTED_COL as EXISTING1 plus EXISTING2
There is more info on computed columns in the CREATE TABLE & ALTER TABLE topics in SQL books online.
Hope this helps!
Cheers,
mia
Life moves pretty fast. If you don't stop and look around once in a while, you could miss it.
November 18, 2003 at 6:07 am
Thanks. Just what I needed
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply