常用sql

1. 根据生日计算当前年龄

   select FLOOR(datediff(Dd,'1949-6-21',getdate())/365.25)

2. 随机生成一定范围内的日期

   CONVERT(varchar(100), dateadd(DAY,cast( floor(rand()*-5) as int),GETDATE()), 120)

3. 随机生成18位数字

   cast( floor(rand()*1000000000000000000) as bigint)

原文地址:https://www.cnblogs.com/keepSmile/p/11056977.html