Saturday, 26 July 2014

Computed column in SQL

No comments
1>Create table
2>Enter column name and datatype
3>goto column property of that column which we wants computed
4>goto Computed Column Specification
5>In formula write your computed formula

like

(case when [start_date]<=getdate() AND [end_date]>=getdate() then 'active' else 'closed' end)

or using sql query

alter table test add status as(case when [start_date]<=getdate() AND [end_date]>=getdate() then 'active' else 'closed' end)