在mssqlserver2005中
要把数据库文件1.txt导入到A数据库的ww表中?
怎么操作或是语句怎么写
谢谢

解决方案 »

  1.   


    EXEC master..xp_cmdshell 'BCP dbo.ww in c:\1.txt -c -T' 
      

  2.   

    对,用bcp
    可以运行cmd,运行bcp命令
    C:\Documents and Settings\Administrator>bcp --help
    用法:  bcp {dbtable | query} {in | out | queryout | format} datafile
      [-m maxerrors]            [-f formatfile]          [-e errfile]
      [-F firstrow]             [-L lastrow]             [-b batchsize]
      [-n native type]          [-c character type]      [-w wide character type]
      [-N keep non-text native] [-V file format version] [-q quoted identifier]
      [-C code page specifier]  [-t field terminator]    [-r row terminator]
      [-i inputfile]            [-o outfile]             [-a packetsize]
      [-S server name]          [-U username]            [-P password]
      [-T trusted connection]   [-v version]             [-R regional enable]
      [-k keep null values]     [-E keep identity values]
      [-h "load hints"]
      

  3.   

    pigengler :
    给出一个实例。
    例如:
    要把c盘根目录下1.txt文件导入到A数据库的ww表中语句怎么写?
    C:\Documents and Settings>bcp
    用法: bcp {dbtable | query} {in | out | queryout | format} 数据文件
      [-m 最大错误数]             [-f 格式化文件]         [-e 错误文件]
      [-F 首行]                   [-L 末行]             [-b 批大小]
      [-n 本机类型]               [-c 字符类型]         [-w 宽字符类型]
      [-N 将非文本保持为本机类型] [-V 文件格式版本]     [-q 带引号的标识符]
      [-C 代码页说明符]           [-t 字段终止符]       [-r 行终止符]
      [-i 输入文件]               [-o 输出文件]         [-a 数据包大小]
      [-S 服务器名称]             [-U 用户名]           [-P 密码]
      [-T 可信连接]               [-v 版本]             [-R 允许使用区域设置]
      [-k 保留空值]               [-E 保留标识值]
      [-h"加载提示"]              [-x 生成 xml 格式化文件]
      

  4.   

    http://topic.csdn.net/t/20061016/21/5086676.html
      

  5.   

    free1879 :运行:EXEC zhaopin..xp_cmdshell 'BCP dbo.dm_mx in c:\11.txt -c -T'
     output
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Native Client][SQL Server]用户 'NT AUTHORITY\SYSTEM' 登录失败。
    SQLState = 42000, NativeError = 4060
    Error = [Microsoft][SQL Native Client][SQL Server]无法打开登录所请求的数据库 "dbo"。登录失败。
    NULL
      

  6.   

    exec 
    bcp   "select   *   from   zhaopin.dbo.dm_mx "   queryout  c:\11.txt   -c   -S 服务器  -U sa   -P 密码
    消息 102,级别 15,状态 1,第 2 行
    'queryout' 附近有语法错误。
    11.txt放在c盘根目录下