我目前正在使用以下数据仓库进行日常工作:
DROP TABLE mytable
SELECT firstcolumn, secondcolumn INTO mytable
FROM OPENQUERY (mylinkedserver, 'SELECT firstcolumn, secondcolumn FROM linkedtable')
我想开始使用TRUNCATE(持久化系统资源和索引):
TRUNCATE TABLE mytable
INSERT INTO mytable (firstcolumn, secondcolumn)
?
如何将OpenQuery与INSERT INTO语句一起使用?
答案 0 :(得分:8)
我相信语法是:
TRUNCATE TABLE mytable
INSERT INTO mytable (firstcolumn, secondcolumn)
SELECT firstcolumn, secondcolumn
FROM OPENQUERY (mylinkedserver, 'SELECT firstcolumn, secondcolumn FROM linkedtable')
答案 1 :(得分:2)
你有没有尝试过:
INSERT INTO mytable(firstcolumn, secondcolumn)
SELECT firstcolumn, secondcolumn
FROM OPENQUERY
(
mylinkedserver,
'SELECT firstcolumn, secondcolumn FROM linkedtable'
);