无法使用链接服务器插入远程服务器

时间:2017-11-16 08:20:20

标签: sql-server

我有以下查询,当源表和目标表位于同一台服务器上时工作,但是当它们位于不同的服务器上时不起作用。但是,如果我只运行select,它会拉出记录但不插入。

INSERT INTO [GBIPS-I-DB324D].[CoreReferenceStaging].[dbo].[tempCompany] 

    select
        fp.companyId,fp.fiscalYear,fp.fiscalQuarter,fi.financialperiodid, fi.periodEndDate,
        fc.currencyId,fp.periodtypeid,ROW_NUMBER() OVER (PARTITION BY fp.companyId, 
        fp.fiscalYear, fp.fiscalQuarter ORDER BY fi.periodEndDate DESC) rowno   

    from 
        ciqFinPeriod fp
        inner join ciqcompany c on c.companyId = 36623 
        --fp.companyId

        join ciqFinInstance fi on fi.financialperiodid = fp.financialperiodid
        join ciqFinInstanceToCollection ic on ic.financialInstanceId = fi.financialInstanceId
        left  join ciqFinCollection fc on fc.financialCollectionId = ic.financialCollectionId
        left join ciqFinCollectionData fd on fd.financialCollectionId = fc.financialCollectionId
    where 
        fp.periodTypeId = @periodtypeId
        and fi.periodenddate >= @date
        and fi.financialInstanceId > @maxFinancialInstanceId

如果我查询select,我会得到结果,但它似乎没有插入,也没有抛出错误。

我也尝试了以下内容,但是在源服务器名称前加上了它,但它并没有什么区别

 INSERT INTO [GBIPS-I-DB324D].[CoreReferenceStaging].[dbo].[tempCompany] 
select top 10
        fp.companyId,fp.fiscalYear,fp.fiscalQuarter,fi.financialperiodid, fi.periodEndDate,
        fc.currencyId,fp.periodtypeid,ROW_NUMBER() OVER (PARTITION BY fp.companyId, 
        fp.fiscalYear, fp.fiscalQuarter ORDER BY fi.periodEndDate DESC) rowno   

    from 
        [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqFinPeriod fp
        inner join [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqcompany c on c.companyId = 36623 
        --fp.companyId

        join [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqFinInstance fi on fi.financialperiodid = fp.financialperiodid
        join [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqFinInstanceToCollection ic on ic.financialInstanceId = fi.financialInstanceId
        left  join [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqFinCollection fc on fc.financialCollectionId = ic.financialCollectionId
        left join [GBIPS-I-DB48D\SQL2008R2].[xpressfeed_dev].[dbo].ciqFinCollectionData fd on fd.financialCollectionId = fc.financialCollectionId
    where 
        fp.periodTypeId = @periodtypeId
        --and fi.financialInstanceId > @maxFinancialInstanceId

0 个答案:

没有答案