Conditional insertion in SqlServer Compact Edition

Is there a way to do conditional insertion in the compact version? I tried two ways that I think will work on 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 ]
+3
source share
1 answer

Why not:

INSERT INTO CUSTQUOTE (QTE_ID) 
SELECT 1
FROM JOB WHERE JOB_NUMBER = 'EW090800345'

or TOP 1 if JOB_NUMBER is not unique

+2
source

Source: https://habr.com/ru/post/1717363/


All Articles