scptxfr.exe的路径要正确
declare @cMd varchar(1000)
set @cmd = 'master.dbo.xp_cmdshell ' + 
'''c:\"Microsoft ' +
'SQL Server"' +
'\MSSQL\Upgrade\scptxfr.exe ' +
' /s YourServerName /p YourSAPassword /I /d YourDBName /f ' +
'c:\YourDBName.sql'''
exec (@cmd)

工具参数说明:
SCPTXFR /s <server> /d <database> {[/I] | [/P <password>]}
        {[/F <script files directory>] | [/f <single script file>]}
        /q /r /O /T /A /E /C <CodePage> /N /X /H /G /Y /?
/s - Indicates the source server to connect to.
/d - Indicates the source database to script.
/I - Use integrated security.
/P - Password to use for 'sa'. Note that login ID is always 'sa'.
     If /P not used or if a password does not follow the flag,
     a null password is used. Not compatible with /I.
/F - The directory into which the script files should be generated.
     This means one file is generated for each category of objects.
/f - The single file in which all script is to be saved.
     Not compatible with /F.
/q - Use quoted identifiers in the generated scripts.
/r - Include drop statements for the objects in the script.
/O - Generate OEM script files.  Cannot be used with /A or /T.
     This is the default behavior.
/T - Generate UNICODE script files.  Cannot be used with /A or /O.
/A - Generate ANSI script files.  Cannot be used with /T or /O.
/? - Command line help.
/E - Stop scripting when error occurs.
     Default behavior is to log the error, and continue.
/C - Indicate the CodePage which overrides the server CodePage.
/N - Generate ANSI PADDING.
/X - Script SPs and XPs to separate files.
/H - Generate script files without header (default: with header).
/G - Use the specified server name as the prefix for the generated             
     output files(to handle dashes in server name).
/Y - Generate script for Extended Properties (valid for 8.x server 
     only).

MSSQL生成整个数据库的SQL脚本的工具 scptxfr.exe的更多相关文章

  1. JAVA 自动生成对应数据库表的JPA代码工具

    http://blog.csdn.net/zheng2008hua/article/details/6274659 关键词:JPA 数据库表代码自动生成,JPA代码生成     自动生成对应数据库表的 ...

  2. Excel生成Oracle数据库表sql工具类

    1.解决问题: 开发文档中字段比较多的时候,建表sql(Oracle下划线命名规范)比较麻烦,容易出错~~ (主要是懒) 特意手写一个工具,根据excel字段,生成建表的sql语句. ~~~末尾附Gi ...

  3. mssql sqlserver两条求和sql脚本相加的方法分享

    转自:http://www.maomao365.com/?p=7205 摘要: 下文分享两条sql求和脚本,再次求和的方法分享 /* 例: 下文已知两条sql求和脚本,现需对两张不同表的求和记录再次求 ...

  4. mssql sqlserver 使用SSMS运行sql脚本的六种方法分享

    摘要: 下文讲述五种运行sql脚本的方法,如下所示: 实验环境:sql server 2008 R2 在一次会议讨论中,大家咨询我使用SSMS运行sql脚本的方法,下文我将依次举例讲述sql脚本的运行 ...

  5. 完整备份和差异备份数据库的SQL脚本

    工作中需要创建SQL Job对数据库进行定期备份,现把脚本记录如下. 1. 完整备份: -- FULL declare @filename varchar(1024), @file_dev varch ...

  6. Mysql数据库导出sql脚本

    1. 运行环境Centos mysqldump -h localhost -u root -p etv > ./etv.sql etv 是要导出的数据库名 > 设置导出的路径和文件名

  7. 常用有效检测数据库运行状态SQL脚本

    1.查看数据库中不为 InnoDB 引擎的表   SELECT TABLE_SCHEMA, TABLE_NAME, ENGINE   FROM information_schema.TABLES  W ...

  8. 【SQL Server 学习系列】-- 随机生成日期时间的SQL脚本

    DECLARE @dt1 DATETIME,@dt2 DATETIME,@a BIGINT,@b BIGINT SET @dt1='2010-01-01'--开始日期 SET @dt2='2010-0 ...

  9. [SQL SERVER] - 还原数据库备份(SQL脚本),抛出 "System.OutOfMemoryException" 异常之解决

    背景 在 Microsoft SQL Server 2016 的查询窗体中,直接还原备份数据库的 SQL 脚本(99MB),抛出 Cannot execute script 异常: 原因 相关资料说: ...

随机推荐

  1. MySQL源码之mysqld启动

    启动mysqld,并进入listen阶段   函数调用栈: mysqld_main():        my_init();初始化变量,锁,错误串      my_thread_global_init ...

  2. 在网页中插入CSS样式表的几种方法

    1. 链入外部样式表 链入外部样式表是把样式表保存为一个样式表文件,然后在页面中用<link>标记链接到这个样式表文件,这个<link>标记必须放到页面的<head> ...

  3. 【转】iOS开发:开发证书知识点总结

    原文网址:http://www.jianshu.com/p/9c166a5e4930 1. Error: An App ID with identifier "*" is not ...

  4. 基于SharePoint 的企业信息平台架构

  5. 项目杂记(MONTHS_BETWEEN,Having ,Spool)

    1,oracle中计算年龄: select FLOOR(MONTHS_BETWEEN(SYSDATE, to_date('20130728', 'yyyymmdd')) / 12), trunc(mo ...

  6. 在Mac下如何开Wifi

    1. 首先打开系统偏好设置,选择共享 2. 把互联网共享给勾上 在里面选择共享来源为以太网,共享方式为Wifi 3. 点开Wifi选项,在里面设置密码(如果需要设置密码的话) 4. 然后看状态栏上的W ...

  7. linux 下信号处理命令trap && linux下各种信号的意义

    1.用途说明 trap是一个shell内建命令,它用来在脚本中指定信号如何处理.比如,按Ctrl+C会使脚本终止执行,实际上系统发送了SIGINT信号给脚本进程,SIGINT信号的默认处理方式就是退出 ...

  8. PG数据库之间的导入导出

    本文将介绍如何对PG数据库进行导入.导出,主要利用的是PG自带的pg_dump.pg_dumpall.pg_restore.psql等命令,版本是9.4(不同版本的pg_dump \ pg_resto ...

  9. 【JAVA - SSM】之MyBatis插入数据后获取自增主键

    很多时候,我们都需要在插入一条数据后回过头来获取到这条数据在数据表中的自增主键,便于后续操作.针对这个问题,有两种解决方案: (1)先插入,后查询.我们可以先插入一条数据,然后根据插入的数据的各个字段 ...

  10. 之前学习wordpress的几张图片