|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, March 26, 2012 5:05 AM
Points: 16,
Visits: 136
|
|
Create table #Test ( emp_id int emp_Birth_Date emp_Age int AS datediff(d,emp_Birth_Date, getdate()) )
....this computed field cannot work....i need the field to automatically calculate the differece and retains number as results.....any help.
thanks.
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:33 PM
Points: 37,741,
Visits: 30,019
|
|
What do you mean by 'cannot work'? Is it giving an error? Is it not giving the values you want? Something else?
Calculated columns are not stored, they're calculated when the column is queried.
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, March 26, 2012 5:05 AM
Points: 16,
Visits: 136
|
|
| giving an error message (Incorrect syntax near the keyword 'AS')
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, March 26, 2012 5:05 AM
Points: 16,
Visits: 136
|
|
| giving an error message (Incorrect syntax near the keyword 'AS')
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Today @ 2:33 PM
Points: 37,741,
Visits: 30,019
|
|
You don't specify a data type when creating a computed column. The data type depends on the result of the expression.
Create table #Test ( emp_id int, emp_Birth_Date DATETIME, emp_Age AS datediff(d,emp_Birth_Date, getdate()) )
Gail Shaw Microsoft Certified Master: SQL Server 2008, MVP SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter We stand on the bridge and no one may pass
|
|
|
|