Link to home
Start Free TrialLog in
Avatar of AlHal2
AlHal2Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Computed Columns vs Scalar Functions

Suppose I have a SQL table with some date columns and I want to calculate the difference.  Should I write a stored procedure using the datediff function or set up a new persisted computed column.
From what I've seen it seems that a computed column will make the stored procedure run faster, but will take up more disk space.
Is this correct?
If diskspace is not an issue should one always use computed columns instead of scalar functions or are there exceptions?
If diskspace is an issue are there any scalar functions that slow queries down more than others?
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AlHal2

ASKER

Thanks.