ALL >> Computer-Programming >> View Article
Sqlyoga: Adding Computed Columns In Sql Server
A scenario that required me to add one calculated column came up today. When a column is computed, it can be used in queries just like any other column and allows us to change one or more columns from the same table.
Lets try it:
Create One Table: tblTestComputed
CREATE TABLE tblTestComputed(
FirstName VARCHAR(50),
LastName VARCHAR(50)
)
Lets insert some data into it:
INSERT INTO tblTestComputed(FirstName, LastName)
SELECT 'Tejas', 'Shah'
UNION
SELECT 'Hiral', 'Shah'
So now I run:
SELECT * FROM tblTestComputed
I will get output like:
Output
I now require the display name to be something like “Shah Tejas” or “Shah Hiral”. I therefore created a new column and named it:
ALTER TABLE tblTestComputed
ADD FullName AS (ISNULL(LastName,'') + ' ' + ISNULL(FirstName,''))
So, now if I run:
SELECT * FROM tblTestComputed
So, Output like:
Output
Add a computed column called FullName to your table to combine first and last names, updating automatically.
However, it’s essential to note that ...
... computed columns cannot be updated directly since they are derived from other columns.
For a deeper dive into computed columns and their applications, click here to learn more. Join SQLYoga to boost your SQL and database skills with tutorials, articles, and expert tips. Be part of a growing community of learners.
Add Comment
Computer Programming Articles
1. Quick & Reliable Otdr & Splicing Machine Service In MumbaiAuthor: bdean
2. Compiler Design Tutorial: Step-by-step Explanation Of All Compiler Phases
Author: Tech Point
3. Learn Design And Analysis Of Algorithms Tutorial With Simple Examples
Author: Tech Point
4. Empowering Businesses With Custom Software Development
Author: Rudram Technology Solutions
5. Website Design Company In Coimbatore – Build A Strong Digital Presence
Author: Icore
6. Vetted Indian Software Engineers: Which Platforms Actually Deliver And What Roi Should You Expect
Author: doaguru infosystems
7. Top Programming Languages & Frameworks We're Using For Custom Projects In 2026
Author: PawanReddy
8. The Top 10 Custom Software Development Trends Shaping 2026
Author: PawanReddy
9. Dbms Tutorial: Step-by-step Guide To Master Database Management System
Author: Tech Point
10. Learn Programming Efficiently With A Data Structures And Algorithms Tutorial
Author: Tech Point
11. How To Choose The Best Cybersecurity Certification That Offers Top Career Opportunities For You
Author: Lorcam Securities
12. Best C# Tutorial 2026: Master C# For Web And Desktop Development
Author: Tech Point
13. Data Center Cooling Market Growth, Trends & Forecast 2032 | Gmr
Author: Caitan Cruz
14. Ceh, Oscp, Or Comptia Security+: Which Cybersecurity Certification Is Best For You?
Author: Lorcam Securities
15. Microsoft Power Automate Workflow Automation Services
Author: brainbell10






