image类型字段的存取
我用sql server2000数据库,其中有content字段,其类型是image
我 向其中写数据,后读出来,还原成原来的文件后,如果32kb以下的能正常读取
但是超过32kb后,将不能读取,格式不正确,文件被损坏,且文件大小只有32kb
不知是何原因,各位能否予以解答!!!!!!!!!!
推荐阅读
不会吧,你试试:
用image类型
方法:
1、建立过程
create procedure sp_textcopy (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
as
declare @exec_str varchar (255)
select @exec_str =
textcopy /s + @srvname +
/u + @login +
/p + @password +
/d + @dbname +
/t + @tbname +
/c + @colname +
/w " + @whereclause +
" /f + @filename +
/ + @direction
exec master..xp_cmdshell @exec_str
2、建表和初始化数据
create table 表名 (编号 int,image列名 image)
go
insert 表名 values(1,0x)
insert 表名 values(2,0x)
go
3、读入
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\图片.bmp,where 编号=1,i --注意条件是 编号=1
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\bb.doc,where 编号=2,i --注意条件是 编号=2
go
4、读出成文件
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\图片.bmp,where 编号=1,o --注意条件是 编号=1
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\bb.doc,where 编号=2,o --注意条件是 编号=2
go
不会吧,你试试:
用image类型
方法:
1、建立过程
create procedure sp_textcopy (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
as
declare @exec_str varchar (255)
select @exec_str =
textcopy /s + @srvname +
/u + @login +
/p + @password +
/d + @dbname +
/t + @tbname +
/c + @colname +
/w " + @whereclause +
" /f + @filename +
/ + @direction
exec master..xp_cmdshell @exec_str
2、建表和初始化数据
create table 表名 (编号 int,image列名 image)
go
insert 表名 values(1,0x)
insert 表名 values(2,0x)
go
3、读入
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\图片.bmp,where 编号=1,i --注意条件是 编号=1
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\bb.doc,where 编号=2,i --注意条件是 编号=2
go
4、读出成文件
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\图片.bmp,where 编号=1,o --注意条件是 编号=1
sp_textcopy 你的服务器名,sa,你的密码,库名,表名,image列名,c:\bb.doc,where 编号=2,o --注意条件是 编号=2
go
transact-sql 参考
set textsize
指定由 select 语句返回的 text 和 ntext 数据的大小。
语法
set textsize { number }
参数
number
是 text 数据的大小,以字节为单位。set textsize 的最大设置为 2 gb。设置值为 0 时将大小重置为默认值 (4 kb)。
注释
设置 set textsize 会影响 @@textsize 函数。
db-library 变量 dbtextlimit 也限制由 select 语句返回的 text 数据大小。如果将 dbtextlimit 设置为小于 textsize 的大小,将只返回 dbtextlimit 所指定的数量。有关更多信息,请参见 sql server 联机丛书中的"用于 c 语言的 db-library 程序设计"。
sql server odbc 驱动程序和用于 sql server 的 microsoft ole db 提供程序在连接时自动将 textsize 设置为 2147483647。
set textsize 的设置是在执行或运行时设置,而不是在分析时设置。
权限
set textsize 权限默认授予所有用户。
请参见
数据类型
set
@@textsize
©1988-2000 microsoft corporation。保留所有权利。


讨论区