根据 SQL 服务器中只有年份的列计算年龄

Calculating age based on a column that has only years in it in SQL Server

我的 table Employee 中有一个名为 BirthYear 的列,它只存储出生年份而不是整个生日。我需要仅使用 SQL 服务器中的 BirthYear 数据来计算每个员工的年龄。我该怎么做?

这是您计算年龄的查询

select DATEPART(year, getdate()) - BirthYear from Employee