导航

使用textcopy对sqlserver的Image字段进行读取和写入

Posted on 2007-05-31 14:24  山姆蜀黍  阅读(2751)  评论(0编辑  收藏  举报
  由于类型的特殊性,对于sqlserver 2000的image字段的读取和写入操作通常会给人带来一些麻烦。应急的时候,我们并不想去重新写代码来操作数据。因此大多数情况下人们会使用textcopy这个工具(老早老早以前有人说可以用存储过程,实际上存储过程中最终也是调用的textcopy)。由于没有gui(提示符下),一些初学这可能会有些困惑。前两天就遇到一个,因此现在在将这个古老的小问题拿出来聊两句,呵呵。
  说实话,也不想多说。运行->cmd->进入提示符下然后cd进入'disc:\Program Files\Microsoft SQL Server\MSSQL\Binn>'目录敲入textcopy,跟着提示一步一步操作就行了。不明白的地方看下边;)

上传交互(cmd)操作如下:
 1 C:\Program Files\Microsoft SQL Server\MSSQL\Binn>textcopy
 2 TEXTCOPY Version 1.0
 3 DB-Library version 8.00.194
 4 Type the SQL Server to connect to: 220.**.**.*      
 5 Type your login: sa
 6 Type your password: sa
 7 Type the database: Product
 8 Type the table: Image
 9 Type the text or image column: data
10 Type the where clause: where id=16
11 Type the file: c:\abc.gif
12 Type the direction ('I' for in, 'O' for out):I
13 Data copied into SQL Server image column from file 'c:\abc.gif'.
下载:
 1 C:\Program Files\Microsoft SQL Server\MSSQL\Binn>textcopy
 2 TEXTCOPY Version 1.0
 3 DB-Library version 8.00.194
 4 Type the SQL Server to connect to: 220.**.**.* 
 5 Type your login: sa
 6 Type your password: sa
 7 Type the database: Product
 8 Type the table: Image
 9 Type the text or image column: data
10 Type the where clause: where id=16
11 Type the file: c:\abc.gif
12 Type the direction ('I' for in, 'O' for out): O
13 Data copied out of SQL Server image column into file 'c:\abc.gif'..