Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何转换bigint为nvarchar使用以下方案:
bigint
nvarchar
1
0001
123
0123
这是一个可能的解决方案:
declare @i bigint SET @i = 125 select right( '0000' + ltrim( str( @i ) ), 4 )
's 的轻微变化danihp,但使用REPLICATE函数。
danihp
REPLICATE
DECLARE @aVar bigint SELECT @aVar = 123; SELECT RIGHT(REPLICATE('0', 4) + LTRIM(STR(@aVar)), 4)
将返回0123