• SQLserver单表数据导入导出


     1 EXEC sp_configure 'show advanced options', 1
     2 
     3 GO
     4 
     5 RECONFIGURE
     6 
     7 GO
     8 
     9 EXEC sp_configure 'xp_cmdshell', 1
    10 
    11 GO
    12 
    13 RECONFIGURE
    14 
    15 GO
    16 //导出
    17 EXEC userinfo..xp_cmdshell 'bcp userinfo.dbo.students out D:studentes.txt -c -T -U''sa'' -P''123456'''

      解释一下 导出

        userinfo:数据库名称

        students:表名

        D:students.txt:导出路径和导入文件名称和类型

        sa:用户名

        123456:密码

       导入

     1 //导入
     2 EXEC userinfo..xp_cmdshell 'bcp userinfo.dbo.students in D:studentes.txt -c -T -U''sa'' -P''123456'''
     3 
     4 EXEC sp_configure 'show advanced options', 1
     5 
     6 GO
     7 
     8 RECONFIGURE
     9 
    10 GO
    11 
    12 EXEC sp_configure 'xp_cmdshell', 0
    13 
    14 GO
    15 
    16 RECONFIGURE
    17 
    18 GO

      导入和上面一样,但是要注意,

      执行完导出或导入工作后,出于对数据库安全性的考虑一定要禁用 'xp_cmdshell'

      我们弄完了要把SQLserver的值改回去,否则会出现各种异常。

    如果有使用请标明来源:http://www.cnblogs.com/duwenlei/
  • 相关阅读:
    求逆元算法
    Almost Sorted Array
    最长不递减子序列
    (LIS)最长上升序列(DP+二分优化)
    rabbitmq延迟消息
    oracle 视图
    oracle 存储过程
    http 会话(session)详解
    系统测试
    Fiddler 手机抓包
  • 原文地址:https://www.cnblogs.com/duwenlei/p/3513682.html
Copyright © 2020-2023  润新知