DOS 选项跳转实现、dos + bcp 双击导入导出数据

DOS 选项跳转实现、dos + bcp 双击导入导出数据

  • option.bat
@echo off
:Start2
cls
goto Start
:Start
title Frequently Used Websites
echo Please select a website from the list
echo with the corresponding key
echo --------------------------------------
echo [1] Google
echo [2] Wikipedia
echo [3] Facebook
echo [4] Youtube
echo [5] Yahoo
set input=
set /p input= Choice:
if "%input%" =="" goto N
if %input%==1 goto Z if NOT goto Start2
if %input%==2 goto X if NOT goto Start2
if %input%==3 goto C if NOT goto Start2
if %input%==4 goto V if NOT goto Start2
if %input%==5 goto B if NOT goto Start2
if %input% gtr 5 goto N

:Z
cls
echo You have selected Google
pause
start www.google.com
exit
:X
cls
echo You have selected Wikipedia
pause
start www.wikipedia.com
exit
:C
cls
echo You have selected Facebook
pause
start www.facebook.com
exit
:V
cls
echo You have selected Youtube
pause
start www.youtube.com
exit
:B
cls
echo You have selected Yahoo
pause
start www.Yahoo.com
exit
:N
cls
echo Invalid Selection! Try again
pause
goto :start2
  • Mantis0000225_ExportSalesOrder_Autosys.cmd
@cls
@echo OFF
@set "endfix=%date:~,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%"
@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION
@echo ...
@echo VALIDATE ENVIRONMENT VARIABLES ...
rem +--------------------------------------------------------------------------+
rem | VALIDATE ENVIRONMENT VARIABLES                                           |
rem +--------------------------------------------------------------------------+

@set MSBACKUP=D:\SalesOrder_NEWDRM
@set MSLOG=D:\SalesOrder_NEWDRM
@set MSTMP=D:\SalesOrder_NEWDRM
@echo ...
@echo DECLARE ALL GLOBAL VARIABLES...
rem +--------------------------------------------------------------------------+
rem | DECLARE ALL GLOBAL VARIABLES.                                            |
rem +--------------------------------------------------------------------------+

@set FILENAME=SALESORDER
@set DB_USERNAME=DRMPOS
@set DB_PASSWORD=DRMPOS
@set TNS_ALIAS=DRMPROD
@set LOGFILE=%MSLOG%\%FILENAME%_%TNS_ALIAS%.log
@set DUMPFILE=%MSBACKUP%\%FILENAME%_%TNS_ALIAS%.dat
rem +--------------------------------------------------------------------------+
rem | WRITE EXPORT PARAMETER FILE.                                             |
rem +--------------------------------------------------------------------------+
@echo ...
@echo MOVE OLD EXPORT (DUMP) FILE....
rem +--------------------------------------------------------------------------+
rem | MOVE OLD EXPORT (DUMP) FILE.                                             |
rem +--------------------------------------------------------------------------+

@if exist "%DUMPFILE%.backup" (del /q "%DUMPFILE%.backup")

@if exist %DUMPFILE% (echo f|@xcopy /y   %DUMPFILE% %DUMPFILE%.backup)
@if exist %LOGFILE% (echo f|xcopy /y  %LOGFILE% "%LOGFILE%.%endfix%")
@if exist "%LOGFILE%.%endfix%" (echo f | xcopy /y  "%LOGFILE%.%endfix%" D:\SalesOrder_NEWDRM\logfile\&del /q "%LOGFILE%.%endfix%")
@if exist %LOGFILE% (del /q %LOGFILE%)
@echo ...
@echo PERFORM EXPORT...
rem +--------------------------------------------------------------------------+
rem | PERFORM EXPORT.                                                          |
rem +--------------------------------------------------------------------------+

rem exp parfile=%PARFILE%
@bcp " select * from drmpos.SALESORDER where orderdate >= convert(DATE,getdate()-10)" queryout %DUMPFILE% -T -c -t^| -d apoms -e %LOGFILE% 

@IF not EXIST %LOGFILE% GOTO end

@echo ...error occured
@echo SCAN THE EXPORT LOGFILE FOR ERRORS...
rem +--------------------------------------------------------------------------+
rem | SCAN THE EXPORT LOGFILE FOR ERRORS.                                      |
rem +--------------------------------------------------------------------------+
@echo ...
@echo Analyzing log file for errors...
@findstr /I /C:"Export terminated unsuccessfully" %LOGFILE%
@if errorlevel 1 (goto good1) else (goto exception)
:END
@echo ...
@echo finished WITHOUT errorlog
@exit /b 0
:good1
@echo ...
@echo Analyzing log file for MS-errors...
@findstr /I /C:"invalid" %LOGFILE%
@if errorlevel 1 (goto good2) else (goto exception)

:good2
@echo ...
@echo Analyzing log file for warnings...
@findstr /I /C:"error" %LOGFILE%
@if errorlevel 1 (goto good3) else (goto exception)

:good3
@echo ...
@echo Analyzing log file for warnings...
@findstr /I /C:"rows" %LOGFILE%
@if errorlevel 1 (cmd /c exit 0) else (goto exception)
@exit /b 0

:exception
@exit /b 1

  • Mantis0000227_ImportSalesOrder_Autosys.cmd
@cls
@echo OFF
@set "endfix=%date:~,4%-%date:~5,2%-%date:~8,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%"
@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION
@echo ...
@echo VALIDATE ENVIRONMENT VARIABLES ...
rem +--------------------------------------------------------------------------+
rem | VALIDATE ENVIRONMENT VARIABLES                                           |
rem +--------------------------------------------------------------------------+

@set MSBACKUP=D:\SalesOrder_NEWDRM
@set MSLOG=D:\SalesOrder_NEWDRM
@set MSTMP=D:\SalesOrder_NEWDRM
@echo ...
@echo DECLARE ALL GLOBAL VARIABLES...
rem +--------------------------------------------------------------------------+
rem | DECLARE ALL GLOBAL VARIABLES.                                            |
rem +--------------------------------------------------------------------------+

@set FILENAME=SALESORDER
@set DB_USERNAME=DRMPOS
@set DB_PASSWORD=DRMPOS
@set TNS_ALIAS=DRMPROD
@set LOGFILE=%MSLOG%\IMP_%FILENAME%_%TNS_ALIAS%.log
@set DUMPFILE=%MSBACKUP%\%FILENAME%_%TNS_ALIAS%.dat
rem +--------------------------------------------------------------------------+
rem | WRITE EXPORT PARAMETER FILE.                                             |
rem +--------------------------------------------------------------------------+
@echo ...
@echo MOVE OLD EXPORT (DUMP) FILE....
rem +--------------------------------------------------------------------------+
rem | MOVE OLD EXPORT (DUMP) FILE.                                             |
rem +--------------------------------------------------------------------------+

@if exist "%DUMPFILE%.backup" (del /q "%DUMPFILE%.backup")

@if exist %DUMPFILE% (echo f|@xcopy /y   %DUMPFILE% %DUMPFILE%.backup)
@if exist %LOGFILE% (echo f|xcopy /y  %LOGFILE% "%LOGFILE%.%endfix%")
@if exist "%LOGFILE%.%endfix%" (echo f | xcopy /y  "%LOGFILE%.%endfix%" D:\SalesOrder_NEWDRM\logfile\&del /q "%LOGFILE%.%endfix%")
@if exist %LOGFILE% (del /q %LOGFILE%)
@echo ...
@echo PERFORM EXPORT...
rem +--------------------------------------------------------------------------+
rem | PERFORM EXPORT.                                                          |
rem +--------------------------------------------------------------------------+

rem exp parfile=%PARFILE%
@bcp apoms.drmpos.SALESORDER in %DUMPFILE% -T -c -t^|  -e %LOGFILE% 

@IF not EXIST %LOGFILE% GOTO end

@echo ...error occured
@echo SCAN THE EXPORT LOGFILE FOR ERRORS...
rem +--------------------------------------------------------------------------+
rem | SCAN THE EXPORT LOGFILE FOR ERRORS.                                      |
rem +--------------------------------------------------------------------------+
@echo ...
@echo Analyzing log file for errors...
@findstr /I /C:"Export terminated unsuccessfully" %LOGFILE%
@if errorlevel 1 (goto good1) else (goto exception)
:END
@echo ...
@echo finished WITHOUT errorlog
@exit /b 0

echo ...
echo Analyzing log file for errors...
findstr /I /C:"Import terminated unsuccessfully" %LOGFILE%
if errorlevel 1 (goto good1) else (goto exception)

:good1
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"communication" %LOGFILE%
if errorlevel 1 (goto good2) else (goto exception)

:good2
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"errors" %LOGFILE%
if errorlevel 1 (goto good3) else (goto exception)

:good3
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"Snapshot" %LOGFILE%
if errorlevel 1 (goto good4) else (goto exception)

:good4
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"TNS" %LOGFILE%
if errorlevel 1 (goto good5) else (goto exception)

:good5
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"resource" %LOGFILE%
if errorlevel 1 (goto good6) else (goto exception)

:good6
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"deadlock" %LOGFILE%
if errorlevel 1 (goto good7) else (goto exception)

:good7
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"identifier" %LOGFILE%
if errorlevel 1 (goto good8) else (goto exception)

:good8
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"maximum" %LOGFILE%
if errorlevel 1 (goto good9) else (goto exception)

:good9
echo ...
echo Analyzing log file for ORA- errors...
findstr /I /C:"shutdown" %LOGFILE%
if errorlevel 1 (goto good10) else (goto exception)

:good10
echo ...
echo Analyzing log file for warnings...
findstr /I /C:"unable" %LOGFILE%
if errorlevel 1 (cmd /c exit 0) else (goto exception)

exit /b 0

:exception
exit /b 1

时间: 2024-11-03 22:01:49

DOS 选项跳转实现、dos + bcp 双击导入导出数据的相关文章

DOS 选择跳转实现、dos + bcp 双击导入和导出数据

DOS 选择跳转实现.dos + bcp 双击导入和导出数据 option.bat @echo off :Start2 cls goto Start :Start title Frequently Used Websites echo Please select a website from the list echo with the corresponding key echo -------------------------------------- echo [1] Google ec

BCP是SQL Server中负责导入导出数据的一个命令行工具

BCP是SQL Server中负责导入导出数据的一个命令行工具,它是基于DB-Library的,并且能以并行的方式高效地导入导出大批量的数据.BCP可以将数据库的表或视图直接导出,也能通过SELECT FROM语句对表或视图进行过滤后导出.在导入导出数据时,可以使用默认值或是使用一个格式文件将文件中的数据导入到数据库或将数据库中的数据导出到文件中. 下面将详细讨论如何利用BCP导入导出数据. 1. BCP的主要参数介绍 BCP共有四个动作可以选择. (1) 导入. 这个动作使用in命令完成,后面

SQL Server BCP 资料导入导出

SQL Server BCP 导入导出使用 Bcp 导出导入数据高效,比使用SQL Server Management Stdio 提供的数据库导出导入要高效因为sql server 也没有提供提供类似oracle的expdp和impdp的工具,如果用SQL Server Management Stdio提供的导入导出对大表数据进行迁移速度太慢了 Bcp 导出数据高效比较适用于大表数据的迁移 进入doc命令行输入bcp命令,就弹出bcp命令的帮助信息: C:\Users\wangwei>bcp

BCP 导入导出数据库数据

使用 bcp 将数据库迁移到 Azure SQL Database --所有 都是在本机sql上运行--先开启cmdshellEXEC sp_configure 'show advanced options', 1GORECONFIGUREGOEXEC sp_configure 'xp_cmdshell', 1GORECONFIGUREGO/**导出指定表的文本文件 */--EXEC master..xp_cmdshell 'bcp MyDB.dbo.Feedbacks out D:\BcpFi

BCP导出导入大容量数据实践

前言 SQL SERVER提供多种不同的数据导出导入的工具,也可以编写SQL脚本,使用存储过程,生成所需的数据文件,甚至可以生成包含SQL语句和数据的脚本文件.各有优缺点,以适用不同的需求.下面介绍大容量数据导出导入的利器——BCP实用工具.同时在后面也介绍BULK INSERT导入大容量数据,以及BCP结合BULK INSERT做数据接口的实践(在SQL2008R2上实践). 1. BCP的用法 BCP 实用工具可以在 Microsoft SQL Server 实例和用户指定格式的数据文件间大

大容量导入和导出数据 -- bcp实用工具

大容量导入和导出数据 -- bcp实用工具 作用 bcp 实用工具可以在SQL Server实例和用户指定格式的数据文件间大容量复制数据. 使用 bcp 实用工具可以将大量新行导入 SQL Server 表,或将表数据导出到数据文件. 除非与 queryout 选项一起使用,否则使用该实用工具不需要了解 Transact-SQL 知识. 若要将数据导入表中,必须使用为该表创建的格式文件,或者必须了解表的结构以及对于该表中的列有效的数据类型. 注意: 如果使用 bcp 备份数据,请创建一个格式化文

数据库bcp导入导出批处理工具

应公司策划要求,需要一个数据库按表导入导出的工具配合svn来进行差异匹配,方便策划每天对数据库修改的记录工具,我使用bcp命令实现如下批处理工具,中间踩了不少坑,现保存在这边希望可以帮到需要此工具的同学. ::数据库地址 set ip=127.0.0.1 ::数据库帐号 set login=sa ::数据库密码 set passward=Passward ::数据库名称 set dataBase=MyDBName ::保存txt文件的路径 set filePath=d:\data::导入到数据库

案例:Oracle exp dmp文件存在坏块并损坏 使用CPFL跳过坏块并成功导入恢复

Oracle数据库exp导出dmp文件损坏存在坏块/corruption通过CPFL工具跳过dmp坏块进发导入 在有些情况下,大家都知道通过dul可以恢复损坏的dmp文件的表的数据,但是该方法有很多问题,特别是对很多数据类型的支持不够完美,比如lob,long raw类型等,而且还有可能恢复出来数据大量丢失,本人通过对dmp结构的分析,使用使用一些特殊的技巧方法,可以实现对于损坏的dmp文件,通过跳过异常坏块所在表,继续恢复后续表,从而最大程度减少损坏 1.创建Oracle测试表 SQL> co

用bcp导sql server数据到excel文件

sql server用bcp来导出数据很方便,比如要导出pubs.dbo.sales的记录成excel格式,在命令提示符下输入: (1)指定表或视图名导出 bcp pubs.dbo.sales out c:\exp.xls -w -S TestDB -U "sa" -P "password" (2)使用select查询语句生成数据悼出 bcp "select * from pubs.dbo.sales" queryout c:\exp.xls -