我需要使用SELECT语句生成的数据填充新列“Better_test”:
SELECT [User Organization], RIGHT([User Organization], LEN([User Organization]) - CHARINDEX(',', [USER ORGANIZATION])) AS Better_test
FROM Logins
下面的代码给出了这个错误: 当未使用EXISTS引入子查询时,只能在选择列表中指定一个表达式。
UPDATE Logins
SET Better_test = ( SELECT [User Organization], RIGHT([User Organization], LEN([User Organization]) - CHARINDEX(',', [USER ORGANIZATION]))
FROM Logins
答案 0 :(得分:1)
您不需要子查询,尤其是返回两个值的子查询。此外,FROM
是不必要的:
UPDATE Logins
SET Better_test = RIGHT([User Organization], LEN([User Organization]) - CHARINDEX(',', [USER ORGANIZATION]);