Looking for a ready-made function, I found that SQL Server users are lazy than me, and I don't even have this basic function! Good, because all I need is the serial number and it will be reset every month, and the maximum ordinal number will not exceed 0.1 million. So use Ribao: declare @ SNintdeclare @ SNLenintset @ SNLen5set @ SN1selectright (0
Looking for a ready-made function, I found that the SQL Server writer is lazy than me, and I don't even have this basic function! Good, because all I need is the serial number and it will be reset every month, and the maximum ordinal number will not exceed 0.1 million. So use rigoal: declare @ SN int declare @ SNLen int set @ SNLen = 5 set @ SN = 1 select right ('0
Looking for a ready-made function, I found that the SQL Server writer is lazy than me, and I don't even have this basic function!
Good, because all I need is the serial number and it will be reset every month, and the maximum ordinal number will not exceed 0.1 million. So use rigth:
Declare @ SN int
Declare @ SNLen int
Set @ SNLen = 5
Set @ SN = 1
Select right ('20140901' + cast (@ SN as varchar (10), @ SNLen)
Set @ SN = 333
Select right ('20140901' + cast (@ SN as varchar (10), @ SNLen)
Set @ SN = 55555
Select right ('20140901' + cast (@ SN as varchar (10), @ SNLen)
These codes may be related:
Declare @ OfYear nvarchar (4)
Declare @ OfMonth nvarchar (2)
Set @ OfYear = datename (yyyy, @ DateTime)
Set @ OfMonth = datename (mm, @ DateTime)
Yes, right