我想有一个临时表,它将使用 select 语句插入值。但每次我运行查询,我总是得到错误
子查询返回超过 1 个值。当查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。该语句已终止。(0 行受影响)
这很奇怪,因为代码中似乎没有错误。但如果有,请纠正我。
这是查询:
DECLARE @tblKeywords TABLE (Keyword1 VARCHAR(MAX), Keyword2 VARCHAR(MAX), Keyword3 VARCHAR(MAX))
Insert into @tblKeywords (Keyword1, Keyword2, Keyword3)
Values(
(Select k from
(Select Keyword k, ROW_NUMBER() OVER (ORDER BY KeywordID) AS RowNum from t_SMSKeyword) as mytable
where mytable.RowNum BETWEEN 1 and 3),
(Select kk from
(Select Keyword kk, ROW_NUMBER() OVER (ORDER BY KeywordID) AS RowNum from t_SMSKeyword) as mytable
where mytable.RowNum BETWEEN 4 and 6),
(Select kkk from
(Select Keyword kkk, ROW_NUMBER() OVER (ORDER BY KeywordID) AS RowNum from t_SMSKeyword) as mytable
where mytable.RowNum BETWEEN 7 and 9)
)
Select * from @tblKeywords