zoukankan      html  css  js  c++  java
  • SQL server2005 將View導入 EXCEL

    ---恢复内容开始---

    怎么将SQLServer2005中 Select 的View 导入Excel,摸索了一天了,先将在网络上查找的资料整理如下:

    方法一:DTS 采用数据库自带的Import方法,给大家一个链接,说的不错,呵呵http://database.ctocio.com.cn/tips/308/8250808_2.shtml 使用SQL Server 2005导出数据到MS Office Excel 2007

    方法一大家注意一下 在填Execl 12.0時,這個一定要寫

    方法二:使用xp_cmdshell 指令,使用时先要启动它,

    -- 允许配置高级选项
    EXEC sp_configure 'show advanced options', 1
    GO
    -- 重新配置
    RECONFIGURE
    GO
    -- 启用xp_cmdshell
    EXEC sp_configure 'xp_cmdshell', 0
    GO
    --重新配置
    RECONFIGURE
    GO

    接着执行命令就好了

    EXEC master..xp_cmdshell 'bcp 库名.dbo.表名out c:\Temp.xls -c -q -S"servername" -U"sa" -P""'
    参数:S 是SQL服务器名;U是用户;P是密码

    在執行方法二的時候我遇到一些為題,在網上搜索到了解決方法,現在列舉一下:

    Error 的原因可能是如下情況引起的

    1) The path/filename is incorrect (check your typing / spelling)

    2) The file does not exist. (make sure the file is where you expect it to be)

    3) The file is already open by some other app. (close the other app to release the file)

    For 1) and 2) - remember that paths are relative to where bcp is executing. Make sure that bcp.exe can access the file/path from it's context.

  • 相关阅读:
    谍战系列
    干将莫邪
    漫话安全众测
    一句话安全
    jsp一句话
    struts2的DevMode模式
    morse code
    Nessus的安装/激活/更新
    WinPcap4.13无法安装解决方法
    安全用网,你应该知道的事
  • 原文地址:https://www.cnblogs.com/karrydong/p/2851478.html
Copyright © 2011-2022 走看看