I tried the SELECT col1, col2, col1+col2 AS col3 FROM table_name command but it only shows the third column but it can not be saved to the table. When I close the SSMS and reopen it nothing is added to the table.
Asked
Active
Viewed 235 times
-1
-
Why would you expect anything to be added to the table? It's just a `SELECT` statement. – Thom A Sep 24 '21 at 18:54
-
A `SELECT` statement is a read-only operation that returns data. It does not modify data or the table schema. It seems you may want a view or computed column to avoid repeating the expression. – Dan Guzman Sep 24 '21 at 18:56
1 Answers
2
It sounds like you're asking for a computed column
Alter table <table>
add col3 as col1 + col2

Stu
- 30,392
- 6
- 14
- 33