Solved

Computed Columns in SQL 2005

Posted on 2008-06-10
3
260 Views
Last Modified: 2010-04-21
Hi

I wanted to created a computed column to raise a column with ints to a power of 2 ( Column ^  2)

What is the syntax in sql ?

Allan
0
Comment
Question by:acadenilla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 21750572
here we go:
ALTER TABLE yourtable ADD x2 as (power(Column,2))  
or 
ALTER TABLE yourtable ADD x2 as (Column*Column) 

Open in new window

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21750584
note: the ^ is bitwise OR, so not appropriate...
0
 

Author Closing Comment

by:acadenilla
ID: 31465702
Thx Angel for the syntax
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question