Guide
Migrating Layers to New Databases
Contact DeLorme Professional Sales for support: 1-800-293-2389 Page 90
SET @ServerName = CONVERT(varchar(100),SERVERPROPERTY('MachineName'))
IF SERVERPROPERTY('InstanceName') IS NOT NULL
BEGIN
SET @SourceServer = @ServerName + '\' +
CONVERT(varchar(100),SERVERPROPERTY('InstanceName'))
END
-- Use temporary table to hold script cmds
create table #xmaplayers (
exportcmd varchar(1000) NOT NULL)
-- cursor for all of the databases on the server
declare c1 cursor for
select name from master.dbo.sysdatabases
where has_dbaccess(name) = 1 -- Only look at databases to which we have access
open c1
fetch c1 into @name
while @@fetch_status >= 0 -- loop through the database looking for GIS layers
begin
Print @name
EXEC ('insert into #xmaplayers (exportcmd) select ''xmapexport --source-server='+@SourceServer+' -
-source-db='+@name+'''+'' --source-layer="''+ [name] + ''" --output-file="''+[name]+''.openspace"'' from ['+
@name+'].dbo.Layers ')
EXEC ('insert into #xmaplayers (exportcmd) select ''xmapimport --target-server='+@TargetServer+' --
target-db='+@name+'''+'' --source-file="''+ [name]+''.openspace"'' from ['+ @name+'].dbo.Layers ')
EXEC ('insert into #xmaplayers (exportcmd) select ''del "''+ [name]+''.openspace"'' from ['+
@name+'].dbo.Layers ')
fetch c1 into @name
end
deallocate c1
select
* from #xmaplaye
rs
drop table #xmaplayers










