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. Helping Travel Leaders Deploy Hotel Rate Comparison AutomationAuthor: webfusion
2. Drive Automated Website Data Collection For Profitable Roi
Author: webfusion
3. How To Monitor Competitor Stock Availability Across Online Retailers
Author: KVETOIQ
4. How Professional It Consultants In Nyc Help Businesses Improve Technology
Author: Sam Vohra
5. How Do You Choose A Commercial Display Fridge For A Supermarket?
Author: Sanjiv Chaudhary
6. Product Matching At Scale: How Retailers Match Exact Products, Variants & Comparable Items Across Marketplaces
Author: KVETOIQ
7. Enterprise Web Crawling At Scale: 10 Requirements For Reliable, Continuously Refreshed Web Data
Author: KVETOIQ
8. Quick Commerce Data Scraping: How Businesses Can Turn Real-time Market Data Into A Competitive Advantage
Author: KVETOIQ
9. Best Data Extraction Companies In India (2026): 8 Managed Providers For Custom Business Data
Author: KVETOIQ
10. Ecommerce Assortment Intelligence: How Retailers Track Product Gaps, New Launches & Category Changes
Author: KVETOIQ
11. Simple Google Maps Business Data Scraping For Global Reach
Author: webfusion
12. Amazon Price Monitoring: How Brands Track Competitor Prices, Discounts & Stock Changes
Author: KVETOIQ
13. Product Engineering Solutions In The Usa: Building Scalable And Innovative Digital Products
Author: John Smith
14. How An Emergency Assembly Point Helps Organize Workplace Evacuations
Author: How an Emergency Assembly Point Helps Organize Wor
15. How To Improve Workplace Safety Awareness Through Daily Practices
Author: scrum






