不幸的是,我无法备份和恢复,因为新数据库使用的是旧版本的 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.
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
问题:哪个前缀是多余的?
实际问题为什么我的 '[',']' 字符没有出现在我的动态 sql 语句中?
您不能使用在远程服务器上创建 new_table
SELECT INTO
换句话说,多余的前缀是远程服务器
您可以通过在远程服务器上创建空表并将动态 SQL 更改为
INSERT INTO server.database.schema.table select from source