我有以下代码,但我收到错误,
Msg 537,Level 16,State 3,Line 1
传递给LEFT或SUBSTRING函数的长度参数无效。
代码:
SELECT
Main.HostName, LEFT(Main.Users, Len(Main.Users) - 1) AS [Users]
FROM
(SELECT DISTINCT
ST2.HostName,
(SELECT ST1.UserName + ', ' AS [text()]
FROM dbo.USERS ST1
WHERE ST1.HostName = ST2.HostName
ORDER BY ST1.HostName FOR XML PATH('')) [Users]
FROM
dbo.USERS ST2) [Main]
我试图让每一行中的大多数用户离开。
答案 0 :(得分:1)
你有Main.Users
空字符串(len = 0)