zoukankan      html  css  js  c++  java
  • BCP导入导出MsSql

    BCP导入导出MsSql

    1、导出数据

    (1)、在Sql Server Management Studio中:

    --导出数据到tset1.txt,并指定本地数据库的用户名和密码
    --这里需要指定数据库完全限定名。
    --username 数据登录名
    --password 数据库密码
    EXEC master..xp_cmdshell 'BCP "SELECT * FROM Testdb.dbo.TestVoucher" queryout d:	set1.txt -c -U"username" -P"password"'

    注:SQL Server阻止了对组件xp_cmdshell过程的解决方案

    复制代码
    sp_configure 'show advanced options',1
    reconfigure
    go
    sp_configure 'xp_cmdshell',1
    reconfigure
    go
    复制代码

    (2)、在CMD中

    BCP "SELECT * FROM Testdb.dbo.TestVoucher" queryout d:	set1.txt -c -S"服务器地址" -U"username" -P"password"

    如图:

    2、导入数据

    (1)、在Sql Server Management Studio中:

     EXEC master..xp_cmdshell 'bcp Testdb.dbo.TestVoucher  in d:	set1.txt -c -T' 

    (2)、在CMD中

    bcp Testdb.dbo.TestVoucher  in d:	set1.txt -c -T

    图:

     
     
     
    标签: 数据库
  • 相关阅读:
    继承和多态
    访问限制
    返回函数
    类和实例
    requests
    函数的参数
    代码块的快速放置
    19进阶、基于TSP的直流电机控制设计
    18进阶、TLC语言
    17高级、Simulink代码生成技术详解
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/3200170.html
Copyright © 2011-2022 走看看