3

我目前每天使用以下内容对表进行数据仓库:

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 语句一起使用?

4

2 回答 2

8

我相信语法是:

TRUNCATE TABLE mytable

INSERT INTO mytable (firstcolumn, secondcolumn)
SELECT firstcolumn, secondcolumn 
FROM OPENQUERY (mylinkedserver, 'SELECT firstcolumn, secondcolumn FROM linkedtable')
于 2012-08-13T20:55:26.783 回答
2

你试过了吗:

INSERT INTO mytable(firstcolumn, secondcolumn)
  SELECT firstcolumn, secondcolumn
  FROM OPENQUERY
  (
    mylinkedserver, 
    'SELECT firstcolumn, secondcolumn FROM linkedtable'
  );
于 2012-08-13T20:54:57.957 回答