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 ...
随机推荐
- laravel 模型观察器
模型观察器 对模型的生命周期内的多个时间点进行监控,分别有 ~ing 和 ~ed 事件 每个监控方法接收 model 作为唯一参数 使用观察器 创建观察器文件,一个普通类,不需要继承什么 针对需要的事 ...
- JAVA(5)之关于main函数的默认放置位置
Eclipse默认主程序入口 Public class 的main函数 package com.study; public class Test { public static void main(S ...
- Python socket day3
UDP聊天室 本地回环(127.0.0.1) 本地回环是每台电脑都有的,只能用于自身电脑的通讯,无论你的IP地址是多少,只要发送方输入的目的IP为127.0.0.1 ,自身便能接受得到数据 测试本地回 ...
- Hadoop学习1—浅谈hadoop
大数据这个词越来越热,本人一直想学习一下,正巧最近有时间了解一下.先从hadoop入手,在此记录学习中的点滴. 什么是hadoop? What Is Apache Hadoop? The Apache ...
- ASP.NET Core搭建多层网站架构【10-使用JWT进行授权验证】
2020/01/31, ASP.NET Core 3.1, VS2019, Microsoft.AspNetCore.Authentication.JwtBearer 3.1.1 摘要:基于ASP.N ...
- cmd创建用户开启3389命令
1.创建用户chen Net user chen 1234566 /add 2.将用户chen添加到管理员组 net localgroup Administrators chen /add 3.开启3 ...
- Uncaught SyntaxError: Unexpected identifier 报错 import Vue from 'vue';
一般情况是因为Webpack与webpack-dev-server版本不兼容导致. package.json { "name": "vue-loader-demo&quo ...
- C++11⾥⾯很好⽤的auto声明
本文摘录于柳神笔记: auto 是C++11⾥⾯的新特性,可以让编译器根据初始值类型直接推断变量的类型.⽐如这样: 当然这个在算法⾥⾯最主要的⽤处不是这个,⽽是在STL中使⽤迭代器的时候, auto ...
- yp寒假训练一
19年东北四省省赛 做了J G C 补了E H J签到题 G 题意: 给n个正方形的两个斜对角点坐标,问最小的移动可以重叠(移动上下左右一格) 思路: 一开始想的是中心pos移动,但是可能有小数,而且 ...
- VUE项目开发中使用WebSocket
初始化WebSocket initWebSocket(){ //初始化weosocket const wsuri = 'ws://10.100.45.8:8888/websocket';//ws地址 ...