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.
这两个查询有什么区别?为什么他们给出不同的结果?
查询 1
DECLARE @test nvarchar SET @test = CONVERT(nvarchar, FLOOR(10.5)) SELECT @test
结果:
['1']
查询 2
SELECT CONVERT(nvarchar, FLOOR(10.5))
['10']
DECLARE @test nvarchar
那是 1 个字符长,因此会截断其分配的值;添加一个(大小)