Subqueries are not allowed in this context. Only scalar expressions are allowed.
我想獲取表中某一列的最大值,然後插入到另外一個表中,報錯的Sql如下:
insert into AA(AA_ID,AA_YWFSRQ) values (NewID(),( SELECT CONVERT(varchar, DATEADD(day,- 1, CAST(SUBSTRING(MAX(YEB_RQ), 1, 4) + SUBSTRING(MAX(YEB_RQ), 5, 2) + SUBSTRING(MAX(YEB_RQ), 7, 2) AS datetime)), 112) FROM YEB ));修正:
insert into AA(AA_ID,AA_YWFSRQ) select NewID(),( SELECT CONVERT(varchar, DATEADD(day,- 1, CAST(SUBSTRING(MAX(YEB_RQ), 1, 4) + SUBSTRING(MAX(YEB_RQ), 5, 2) + SUBSTRING(MAX(YEB_RQ), 7, 2) AS datetime)), 112) FROM YEB )錯誤提示信息:
Subqueries are not allowed in this context. Only scalar expressions are allowed.
==》在此上下文中不允許使用子查詢。隻允許使用標量表達式。
最後更新:2017-04-03 12:56:23