是否可以做一些事情,比如在这样的情况下IF
发表声明INSERT
;
INSERT INTO @TABLE (ID, NAME, ADDRESS)
VALUES(
IF CONDITION (SELECT DATA)
ELSE (SELECT DATA)
)
是否可以做一些事情,比如在这样的情况下IF
发表声明INSERT
;
INSERT INTO @TABLE (ID, NAME, ADDRESS)
VALUES(
IF CONDITION (SELECT DATA)
ELSE (SELECT DATA)
)
有点...
INSERT INTO @TABLE (ID, NAME, ADDRESS)
SELECT
CASE condition WHEN result then id else id2 end,
CASE condition WHEN result then name else name2 end,
...
或与UNION
INSERT INTO @TABLE (ID, NAME, ADDRESS)
SELECT data FROM source WHERE condition
UNION
SELECT data FROM othersource WHERE NOT(condition)