SQL日期
SELECT GETDATE() as '当前日期', DateName(year,GetDate()) as '年', DateName(month,GetDate()) as '月', DateName(day,GetDate()) as '日', DateName(dw,GetDate()) as '星期', DateName(week,GetDate()) as '周数', DateName(hour,GetDate()) as '时', DateName(minute,GetDate()) as '分', DateName(second,GetDate()) as '秒'
sql左侧补0
--第一种方法(五个0,代表五位数) SELECT RIGHT('00000'+CAST(ID AS nvarchar(50)),5) FROM dbo.TableName --左边补0,如 00001,00039 SELECT LEFT(CAST(ID AS nvarchar(50))+'00000',5) FROM dbo.TableName --右边补0,如 10000,39000
--第二种方法 SELECT REPLICATE('0',5-len('39'))+'39' --左边补0, 如 00039 SELECT '39' + REPLICATE('0',5-len('39')) --右边补0,如 39000