Table of Contents
MSSQL OPENQUERY
SELECT * FROM OPENQUERY(L_TESTDB, 'SELECT * FROM LinkedServerTestTable');
INSERT OPENQUERY(L_TESTDB, 'SELECT NO, NAME FROM LinkedServerTestTable ') VALUES (1, '홍길동');
INSERT INTO OPENQUERY (L_TESTDB, 'SELECT AAA, BBB, CCC FROM LinkedServerTestTable')
SELECT AAA, BBB, CCC
FROM tbl_table
where
1 = 1
and AAA >= '2019-08-01'
and AAA < '2019-09-01';
UPDATE OPENQUERY(L_TESTDB, 'SELECT NAME FROM LinkedServerTestTable WHERE NO = 1') SET NAME = '임꺽정';
-- 파라미터는 문자열 합치기를 이용해 전달합니다.
DECLARE @VAL VARCHAR(10);
SET @VAL = '20';
UPDATE OPENQUERY(L_TESTDB, 'SELECT NAME FROM LinkedServerTestTable WHERE NO = ' + @VAL + ' AND BBB = 2') SET NAME = '임꺽정';
-- SELECT * FROM 을 해야 합니다.
-- 삭제할 건수가 많은 경우 매우 느리다.
DELETE OPENQUERY(L_TESTDB, 'SELECT * FROM LinkedServerTestTable WHERE NO = 1');