How to backup on MSSQL by table level ?
MSSQL is good database. Unlike as Oracle, it seems that can not backup sqlserver databasee tables one by one.
However there is always way.
Thanks to
I did modify and then , it can auto baclkup table one by one no matter how many table is.
Here is script:
-- SQL Table Backup
-- Developed by DBATAG, www.DBATAG.com
DECLARE @table VARCHAR(128),
@file VARCHAR(255),
@cmd VARCHAR(512)
declare @m int
declare @n int
--declare @tmp nvarchar(MAX)
declare @tableList TABLE (id int IDENTITY(1,1) NOT NULL,contents VARCHAR(128) NOT NULL)
DECLARE @SQL2 VARCHAR(MAX)
SET NOCOUNT ON
set @SQL2='select DB_NAME()+''.'' +schema_name() + ''.''+ name from sys.tables where type=''U'''
INSERT INTO @tableList (contents) exec (@SQL2)
set @m=(select count(*) from @tableList)
set @n=1
while @n<=@m
begin
set @table=(select contents from @tableList where id=@n)
--SET @table = 'AdventureWorks.Person.Contact' -- Table Name which you want to backup
--SET @table = 'MES.dbo.Sys_Group'
--SET @table = 'select name from sys.tables where type='U' order by 1'
SET @file = 'C:\backup\' + @table + '_' + CONVERT(CHAR(8), GETDATE(), 112) -- Replace C:\MSSQL\Backup\ to destination dir where you want to place table data backup
+ '.bcp'
SET @cmd = 'bcp ' + @table + ' out ' + @file + ' -n -T '
EXEC master..xp_cmdshell @cmd
set @n=@n+1
end
Bingo
How to backup on MSSQL by table level ?的更多相关文章
- flush table with read lock的轻量级解决方案[原创]
为什么要使用FTWRL MySQL dba在日常工作中,数据备份绝对是工作频度最高的工作内容之一.当你使用逻辑方式进行备份(mydumper,mysqldump)或物理方式进行备份(percona ...
- Backup and Recovery Types
Physical(Raw) and Logical Backup: 1.Physical backups consist of raw copies of the directories and fi ...
- flush table with read lock的轻量级解决方案
为什么要使用FTWRL MySQL dba在日常工作中,数据备份绝对是工作频度最高的工作内容之一.当你使用逻辑方式进行备份(mydumper,mysqldump)或物理方式进行备份(percona ...
- RMAN BACKUP
转自 RMAN BACKUP backup terminology Using the RMAN BACKUP Command to Create Backups Server-Managed Con ...
- How to changes to Table & EDT Relations[AX2012]
Well I hope everyone is having a fine week so far. Oh Wednesdays, the furthermost point between two ...
- 13.1.17 CREATE TABLE Syntax
13.1.17 CREATE TABLE Syntax 13.1.17.1 CREATE TABLE ... LIKE Syntax 13.1.17.2 CREATE TABLE ... SELECT ...
- MySQL Error Number 1005 Can’t create table(Errno:150)
mysql数据库1005错误解决方法 MySQL Error Number 1005 Can’t create table ‘.\mydb\#sql-328_45.frm’ (errno: 150) ...
- 102. Binary Tree Level Order Traversal + 103. Binary Tree Zigzag Level Order Traversal + 107. Binary Tree Level Order Traversal II + 637. Average of Levels in Binary Tree
▶ 有关将一棵二叉树转化为二位表的题目,一模一样的套路出了四道题 ▶ 第 102 题,简单的转化,[ 3, 9, 20, null, null, 15, 7 ] 转为 [ [ 15, 7 ] , [ ...
- 转 RMAN: RAC Backup, Restore and Recovery using RMAN
PURPOSE The purpose of this document is to give a quick guide for using RMAN on RAC databases. We wi ...
随机推荐
- word写文档体会
1.找一个文档规范要求. 2.根据文档的规范要求调整正文的格式,标题1的格式,标题2的格式,标题3的格式,图表的格式,把没用的那些格式都删除掉. 3.图注表注后空格一行. 4.设置页眉页脚. 5.生成 ...
- sqli-libs(5-10关)
Less_5 补充基础知识 1. left(a,b)左侧截取a的前b位,正确则返回1,错误则返回o Select left(database(),1)=’s’; 其中database()为sec ...
- ztree-拖拽(排序树)
<!DOCTYPE html> <HTML> <HEAD> <TITLE> ZTREE DEMO - beforeDrag / onDrag / bef ...
- Java面向对象编程 -6.4
二维数组 数组的定义格式 数组的动态初始化:初始化之后数组中的每一个元素的保存的内容为其对应数据类型的默认值 声明并初始化数组: 数据类型 数组名称 [][] = new 数据类型[行个数][列个数] ...
- 学习笔记(22)- plato-训练端到端的模型
原始文档 Train an end-to-end model To get started we can train a very simple model using Ludwig (feel fr ...
- Xcode 编译运行旧项目报错解决之路
运行几年前做的项目,发现各种编译报错,一个一个解决记录下: 1.Xcode(Xcode9)编译运行报错,但是在 issue navigatior 栏看不到错误信息: 解决方案:在 show repor ...
- C/C++中size_t潜在的问题
在C++中,利用数组下标访问数组元素时,常常将下标类型定义为size_t类型,因为正常来说,数组的下标就是size_t类型.例如这样: for (size_t i = 0; i < contai ...
- scrapy import CrawlSpider 报错
from scrapy.spider import CrawlSpider 报错 import module CrawlSpider error 看了下以前一直用的scrapy0.14.1 使用的是B ...
- 最新版自动检测卡片类型工具软件版本(auto check card type v3.2.0)
自动检测卡片类型工具软件. 卡片放到读卡器上面自动识别卡片类型,不需老是按下按钮,好用,方便.支持自动识别NTAG213卡片,NTAG215卡片, NTAG216卡片,Ultralight芯片, Ul ...
- Maven与Nexus
开始在使用Maven时,总是会听到nexus这个词,一会儿maven,一会儿nexus,当时很是困惑,nexus是什么呢,为什么它总是和maven一起被提到呢? 我们一步一步来了解吧. 一.了解Mav ...