不幸的是,我无法备份和还原,因为新的数据库位于较旧版本的SQL上。
当我运行以下脚本时,会得到以下错误:
Msg 117, Level 15, State 1, Line 1
The object name 'eih-dr01.eih.ehs.org.DBA.dbo.fp_monthly' contains more than the maximum number of prefixes. The maximum is 2. declare @table varchar(255),
@sql nvarchar(max)
declare c cursor local for
select st.name from sys.tables st
open c
fetch next from c into @table
set @sql = 'select * into [eih-dr01.eih.ehs.org].DBA.dbo.' + @table + ' from ' + @table
print @sql
exec sp_executesql @sql
fetch next from c into @table
close c
deallocate c问:哪个前缀是多余的?
实际问题为什么我的““,””字符没有出现在我的动态sql语句中?
发布于 2018-07-19 19:26:08
根据选择-进入条款
不能使用new_table在远程服务器上创建
SELECT INTO。
换句话说,多余的前缀是远程服务器。
您可能可以通过在远程服务器上创建空表并将动态SQL更改为
INSERT INTO server.database.schema.table select from source
发布于 2018-07-21 10:16:32
不过,如果我没记错的话,情况正好相反。
将旧服务器链接到新服务器上,并将select语句更改为:
set @sql = 'select * into DBA.dbo.' + @table + ' from [oldserver].dba.dbo.' + @table'没有地方来测试它,但我几乎可以肯定,我在过去做过,它工作得很好。
https://dba.stackexchange.com/questions/212696
复制相似问题