好的,所以我在Technet上搜索了答案,但无济于事。
我只想打印与两个String变量串联的整数变量。
这是我的代码,无法运行:
print 'There are ' + @Number + ' alias combinations did not match a record'
看起来像是一个基本功能,我无法想象在T-SQL中是不可能的。但是,如果不可能,请这样说。我似乎找不到直接的答案。
Answers:
declare @x INT = 1 /* Declares an integer variable named "x" with the value of 1 */
PRINT 'There are ' + CAST(@x AS VARCHAR) + ' alias combinations did not match a record' /* Prints a string concatenated with x casted as a varchar */
仔细检查是否已设置要打印的int和十进制值的初始值。
该样本正在打印一个空行
declare @Number INT
print 'The number is : ' + CONVERT(VARCHAR, @Number)
并且此示例正在打印->数字为:1
declare @Number INT = 1
print 'The number is : ' + CONVERT(VARCHAR, @Number)
print 'There are ' + CAST(@Number AS NVARCHAR(100)) + ' alias combinations did not match a record'