使用windows验证的话,存储过程都要修改
参考这个:
SQL Server中,可以用SQL Server自带的命令行工具Textcopy来实现两个功能:
1、把一个图片文件插入到数据库中
2、从数据库中取出图片保存为一个文件注:
textcopy通常在目录Program Files\Microsoft SQL Server\MSSQL\Binn下一、准备工作
在控制台下使用命令textcopy /? 来获取帮助
我举个实际的例子:
比如我的机器名为:ZB
登陆名:          sa
密码:   密码为空
数据库名   db_test
下面建立一个表:create table tb_test (name char(8), photo image)插入两条数据insert tb_test values('Tom',0x)insert tb_test values('Mary',0x)注意:如果这样insert tb_test values('mary',null),在插入数据的时候就会失败,出错信息为:
ERROR: Text or image pointer and timestamp retrieval failed.
可以尝试一下。另外,在C盘根目录下可以放一个图片文件:1.bmp二、开始插入图片进入命令提示符,键入textcopy命令:以下是我机器上的操作演示:C:\>textcopy
TEXTCOPY Version 1.0
DB-Library version 8.00.194
Type the SQL Server to connect to: ZB
Type your login: sa
Type your password:
Type the database: db_test
Type the table: tb_test
Type the text or image column: photo
Type the where clause: WHERE(name='Tom')
Type the file: c:\1.bmp
Type the direction ('I' for in, 'O' for out): I  
Data copied into SQL Server image column from file 'c:\1.bmp'.也可以使用参数,这样只需要一条语句就可以实现:C:\>textcopy /S ZB /U sa /P  /D db_test /T tb_test /C photo /W WHERE(name='Tom') /F c:\1.bmp /I
TEXTCOPY Version 1.0
DB-Library version 8.00.194
Data copied into SQL Server image column from file 'c:\1.bmp'.
如果采用Windows验证,并且在服务器上操作,那写起来更为方便
textcopy /S /U /P /D db_test /T tb_test /C photo /W WHERE(name='Tom') /F c:\1.jpg /I注:如果是从数据库中取出图片保存为一个文件,只需要把最后参数I改为O即可。