有没有办法在紧凑版中进行条件插入? 我尝试了两种我认为可以在SqlServer上运行的方法:
INSERT INTO CUSTQUOTE (QTE_ID) VALUES (1)
WHERE EXISTS(SELECT * FROM JOB WHERE JOB_NUMBER = 'EW090800345')
There was an error parsing the query. [ Token line number = 2,Token line offset = 1,Token in error = WHERE ]
IF EXISTS(SELECT * FROM JOB WHERE JOB_NUMBER = 'EW090800345')
BEGIN
INSERT INTO CUSTQUOTE (QTE_ID) VALUES (1)
END
There was an error parsing the query. [ Token line number = 1,Token line offset = 1,Token in error = IF ]
答案 0 :(得分:2)
为什么不:
INSERT INTO CUSTQUOTE (QTE_ID)
SELECT 1
FROM JOB WHERE JOB_NUMBER = 'EW090800345'
如果JOB_NUMBER不是唯一的,则或TOP 1