123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Sqlyoga: Adding Computed Columns In Sql Server

Profile Picture
By Author: sqlyoga
Total Articles: 4
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

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.

Total Views: 289Word Count: 186See All articles From Author

Add Comment

Computer Programming Articles

1. Mobile App Design Ui Game Changers
Author: brainbell10

2. Learn Web Design For Marketing With Our Experts
Author: brainbell10

3. Master Full Stack Dev: Tcci South Bopal Ahmedabad 2026
Author: TCCI - Tririd Computer Coaching Institute

4. A Practical Guide To Ecommerce Web Design For 2023
Author: brainbell10

5. Why Managed It Services In New York City Are Essential For Business Growth
Author: Sam Vohra

6. 10 Advantages Of Using Django For Web Development
Author: brainbell10

7. Custom Software Development Services: Why Businesses Need Tailored Software Solutions In 2026
Author: aagamjwk

8. How Much Does Telemedicine App Development Cost?
Author: brainbell10

9. How To Design An App For Ipad?
Author: brainbell10

10. Mobile App Vs Mobile Websites: Which One Should You Choose For Your Business And Why?
Author: brainbell10

11. 8 Tips To Build Your App Clip
Author: brainbell10

12. Best C++ Tutorial For Beginners And Professionals: Learn C++ Step By Step
Author: Tech Point

13. Complete C Tutorial With Examples: Learn Core Concepts And Advanced Techniques
Author: Tech Point

14. Beyond Connectivity: How Digital Financial Services Are Reshaping Telecom Growth
Author: Kevin

15. How To Create The First Wireframe Of Your Application?
Author: brainbell

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: