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 ...
随机推荐
- web前端技能考核(阿里巴巴)
- websocket协议实现
# websocket协议实现 1.抓包 wireshark规则: tcp.port == 9000 2. 结果解析 客户端请求: GET /ws/test_2 HTTP/1.1 Host: loca ...
- python 在linux上面安装beautifulsoup4(bs4) No module named 'bs4'
续费了我的服务器 重做系统成了Linux服务器 然后想把Windown上的Python脚本放上去运行 但是出现了 No module named 'bs4' 的问题 pip install bs4 试 ...
- "exit"未定义标签 问题
找了两个多小时,最后才发现是版本问题.因为是网上下的代码,可能用的版本比较高,而我自己的是2.4.10版本的opencv,所以正确的代码应该是如下: CV_Error(CV_StsBadArg,&qu ...
- oracle错误代码大全(超详细)
本篇文章是对oracle错误代码进行了详细的总结与分析,需要的朋友参考下 ORA-00001: 违反唯一约束条件 (.)ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数 ...
- python二维数组的创建
话不多说,代码伺候 m = [[]*]*3 #创建一个3行5列的二维数组 m[][]= print(m) 输出结果为: 分析: m = [[0]*5]*3只是指向三个空列表的引用. 创建一个二维数组的 ...
- 喵星之旅-狂奔的兔子-基于docker的redis分布式集群
一.docker安装(略) 二.下载redis安装包(redis-4.0.8.tar.gz) 以任何方式获取都可以.自行官网下载. 三.拉取centos7的docker镜像 命令:docker pul ...
- Python:数值类型
数值类型的组成 数值类型可以直接使用的有:整数.浮点数.复数 Python3的整型,可以自动调整大小,当做long使用 整数 int 整数的进制表示 表示形式: 二进制:0b... 八进制:0o... ...
- 【代码审计】VAuditDemo 前台搜索注入
在search.php中 $_GET['search']未经过任何过滤传入到$query的执行语句中
- 吴裕雄--天生自然Numpy库学习笔记:NumPy 切片和索引
ndarray 数组可以基于 0 - n 的下标进行索引,切片对象可以通过内置的 slice 函数,并设置 start, stop 及 step 参数进行,从原数组中切割出一个新数组. import ...