[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Computed Columns in SQL 2005

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
acadenilla
Asked:
acadenilla
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
note: the ^ is bitwise OR, so not appropriate...
0
 
acadenillaAuthor Commented:
Thx Angel for the syntax
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now