--自定义流水号
--格式化数字,前置加0,前导加0
select convert(char(8),getdate(),112)+'_'+(right(cast(power(10,6) as varchar)+1,6))
![](https://i-blog.csdnimg.cn/blog_migrate/d6846434100631456475a4e1f0ece0f6.png)
------------------
select right(cast(power(10,3) as varchar)+33,3)
select right(cast(power(10,3) as varchar)+1,3)
分别格式化33和1
结果为
033
001