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 ...
随机推荐
- 201771010135 杨蓉庆/张燕/杨玲《面对对象程序设计(java)》第十四周学习总结
1.实验目的与要求 (1) 掌握GUI布局管理器用法: (2) 掌握各类Java Swing组件用途及常用API 一.理论知识 Swing和MVC设计模式 (1)设计模式(Design patte ...
- dp(小猪存钱罐)
B - Piggy-Bank 在acm能够做任何事情之前, 必须编制预算并获得必要的财政支持.这一行动的主要收入来自IBM.这个想法其实很简单,每当一些会员有一点小 ...
- 基于SILVACO ATLAS的a-IGZO薄膜晶体管二维器件仿真(02)
Silvaco的破解用了好久好久,而且之后拷了上次例子的代码,Tonyplot的输出存在报错,还是四连. 当然这个点一下还是会出图的.但是,源代码稍微改了下结构,又有报错,而且程序直接终止. go a ...
- sockfd_to_family函数
#include <sys/socket.h> #include <netinet/in.h> #define SA struct sockaddr int sockfd_to ...
- 基于Amoeba读写分离
Amoeba 原理:amoeba相当于业务员,处理client的读写请求,并将读写请求分开处理.amoeba和master以及slave都有联系,如果是读的请求,amoeba就从slave读取信息反馈 ...
- C# 面试编程算法题
求以下表达式的值: 1. 1 - 2 + 3 - 4 + … + m public static int Foo1(int m) { ; ; i <= m; i++) { == ) { sum ...
- SQL语句优化分析
分析比较执行时间计划读取情况 select * from dbo.Product 执行上面语句一般情况下只给你返回结果和执行行数,那么你怎么分析呢,怎么知道优化之后跟没有优化的区别呢. 下面几种方法: ...
- 用for循环写这段代码
之前用while循环写了一段代码,现在改为用for循环来写,代码如下: hongtao_age = 38 for i in range(5): guess_age = int(input(" ...
- Passive Client Feature
Q. How is the passive client feature used on Wireless LAN Controllers? A. Passive clients are wirele ...
- express 应用创建及app.js详解
#1 express 应用创建 1.安装node.js (自行百度) 2.npm install express -g 3.全局安装express生成器 express-generator npm i ...