这似乎很简单...
如何存储多行字符串,以使代码保持良好的格式。
这样做很丑
DECLARE @myStr NVARCHAR(MAX)
SET @myStr = 'This represents a really long
string that i need multiple lines for,
dude.'
但是上面的结果导致正确的字符串输出:
SELECT @myStr
'This represents a really long string that i need multiple lines for, dude.'
这样做可以更轻松地读取我的代码:
DECLARE @myStr NVARCHAR(MAX)
SET @myStr = 'This represents a really long
string that i need multiple lines for,
dude.'
但是会导致:
SELECT @myStr
'This represents a really long string that i need multiple lines for,
dude.'
是否有一些特殊的方法可以使多行字符串中的制表符转义(就像其他每种语言一样)。
答案 0 :(得分:3)
您正在寻找backslash(“ \”):
SET @myStr = 'This represents a really long \
string that i need multiple lines for, \
dude.'