Migration data on SQL
从表里面导出数据XML:
-- export
declare @xml xml
set @xml = (select * from (
select TableName = 'Schema',
xmlData = ( select * from [Schema] where id = 337 for xml auto, root('Schemas') )
union
select 'SchemaFile',
( select Id, SchemaId,
Data = convert(varchar(max), Data),
FileName, Fullpath, RelativePath
from SchemaFile where SchemaId = 337 for xml auto, root('SchemaFiles') ) ) SchemaExport
for xml auto, root('SchemaExports') ) select @xml
将导出XML数据插入到目的表中:
-- now import declare @idoc int declare @tableName varchar(255)
declare @xmlData xml declare @mappingExport table (TableName varchar(255), xmlData xml) exec sp_xml_preparedocument @idoc output, @xml
insert into @mappingExport
select *
from openxml (@idoc, '/SchemaExports/SchemaExport')
with (TableName varchar(255),
xmlData nvarchar(max))
exec sp_xml_removedocument @idoc output declare exportCursor cursor
for select TableName, xmlData
from @mappingExport open exportCursor fetch from exportCursor into @tableName, @xmlData while @@fetch_status <> -1
begin
exec sp_xml_preparedocument @idoc output, @xmlData if (@tableName = 'Schema')
begin
print 'Copying Schema' select *
from openxml (@idoc, '/Schemas/Schema')
with (Id int,
TenantId int,
VersionNo int,
ResponseSchemaId int,
SchemaName nvarchar(200),
SOAPActino varchar(200),
LastUpdatedUTC datetime,
IsCanonical bit,
DocumentType nvarchar(512) )
end
else if (@tableName = 'SchemaFile')
begin
print 'Copying SchemaFile'
select *, datalength(data), convert(xml, data)
from openxml (@idoc, '/SchemaFiles/SchemaFile')
with (Id int,
SchemaId int,
Data varchar(max),
FileName nvarchar(255),
FullPath nvarchar(255),
RelativePath nvarchar(255) )
end
exec sp_xml_removedocument @idoc
fetch next from exportCursor into @tableName, @xmlData
end select datalength(data), convert(xml, data)
from schemafile
where schemaid = 337
Migration data on SQL的更多相关文章
- 如何用rake tasks 生成migration对应的sql
how-to-use-rake-tasks-to-generate-migration-sql Rakefile文件里有load_tasks的方法 http://api.rubyonrails.org ...
- 7.4.1 Dumping Data in SQL Format with mysqldump
7.4 Using mysqldump for Backups 使用mysqldump 用于备份: 7.4.1 Dumping Data in SQL Format with mysqldump 7. ...
- Rails Migration Data Model栏位修改及数据类型介绍
测试版本Ruby:2.3.1 Rails:5.0.1 一.增加栏位 给devise默认的用户新增增加username字段 $ rails generate migration add_ ...
- [Android 开发教程(1)]-- Saving Data in SQL Databases
Saving data to a database is ideal for repeating or structured data, such as contact information. Th ...
- 使用SQL Database Migration Wizard把SQL Server 2008迁移到Windows Azure SQL Database
本篇体验使用SQL Database Migration Wizard(SQLAzureMW)将SQL Server 2008数据库迁移到 Azure SQL Database.当然,SQLAzure ...
- 6 ways to import data into SQL Server
I’m going to go over some methods to import data from text files into SQL Server today. The particul ...
- Android学习笔记——保存数据到SQL数据库中(Saving Data in SQL Databases)
知识点: 1.使用SQL Helper创建数据库 2.数据的增删查改(PRDU:Put.Read.Delete.Update) 背景知识: 上篇文章学习了保存文件,今天学习的是保存数据到SQL数据库中 ...
- Transfer data to SQL Server from SPC-Light with Excel macros
公司的QA检测软件SPC-Light,需要从其中读取一些信息至SQL Server数据库,储存或是做其它分析. 先是在Excel的VBE的工具中,引入一个组件Microsoft ActiveX Dat ...
- Link static data in sql source control
You can link data that doesn't change very often to SQL Source Control. This lets you commit data ch ...
随机推荐
- 30款javascript脚本插件 jquery插件大全
Shifty Nav - a Fully Responsive JS CSS3 Mega Menu Show Demo Shifty Nav is a fully responsive CSS3 ...
- [LeetCode][Python]Roman to Integer
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/roman-t ...
- eclipse 中修改 M2_REPO的值
转自: http://blog.csdn.net/xuechongyang/article/details/8267440 从eclipse中增加了maven2的插件之后,maven默认的本地库的路径 ...
- md笔记——编程术语
thinkPython 读书笔记 本列表根据thinkPython中记录的大量编程术语 整理而来. 该书的重点不是教会你Python,而是培养读者用计算机科学家一样的思路来思考,设计,开发. 讲解了语 ...
- matlab GUI之 -- 绘图
1.常用属性 linestyle: 实线 - 虚线 -- 点线 : 点画线 -. marker: 加号 + 圆圈 O 星号 * 方块 S 三角形 ^ < > 五角星 P color: ...
- 创建oracle数据库的表空间、用户、目录、导入\导出文件等信息
1.创建表空间 create tablespace ts_aw logging datafile 'd:\app\Administrator\product\tablespace\ts_aw.dbf' ...
- 向上取整Ceil,向下取整Floor,四舍五入Round
几个数值函数的功能实现: (1)int Ceil(float f) int Ceil(float f) { int integer = (int)f; if (f > (float)intege ...
- Nginx +iis反向代理
一:简介 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所 ...
- Log4net 自定义字段到数据库
今天要求做个log4net自定义字段到数据库,在网上找了好多例子,都运行不成功.最后找了个国外的,很简单的就解决了. log4net它已经定义的字段有 <commandText value=&q ...
- 优秀的 Android Studio 插件
转自:http://www.codeceo.com/article/8-android-studio-plugins.html Android Studio是目前Google官方设计的用于原生Andr ...