sql server中的ntext字段类型怎么读取?

ttyp 2001-05-22 01:15:00
我把ACCESS到入到SQL SERVER中,其中的MEMO字段变为NTEXT字段,用R!字段不能读取,要怎么才能读呢?
...全文
279 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangsaibing 2001-05-22
  • 打赏
  • 举报
回复
请建立一个conNorthWind数据源,连接到MS SQL Server。
SQL Server上有一数据库名为NorthWind,该库里的Employees表里的Notes字段即为
nText类型,如下代码可以从数据库里读出它:
Set obj = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.RecordSet")
obj.open "conNorthWind", "sa", ""
rs.open "select employeeid ,notes from northwind.dbo.employees", obj
MsgBox rs(0)
MsgBox rs(1)
ttyp 2001-05-22
  • 打赏
  • 举报
回复
有例子吗?
ttyp 2001-05-22
  • 打赏
  • 举报
回复
to tom255(appleben):谢谢你,但我不是很明白,如果找出这条记录,要获得记录中某字段的值,怎么做?

如:select a from b where .. (a 为NTEXT行的)

readtext 怎么用?
怎么获得该字段的大小
wwq_jeff 2001-05-22
  • 打赏
  • 举报
回复
READTEXT
读取 text、ntext 或 image 列中的 text、ntext 或 image 值,从指定的偏移量开始读取指定的字节数。

语法
READTEXT { table.column text_ptr offset size } [ HOLDLOCK ]

参数
table.column

是从中读取的表和列的名称。表名和列名必须符合标识符的规则。必须指定表名和列名,不过可以选择是否指定数据库名称和所有者名称。

text_ptr

有效文本指针。text_ptr 必须是 binary(16)。

offset

开始读取 text、image 或 ntext 数据之前跳过的字节数(使用 text 或 image 数据类型时)或字符数(使用 ntext 数据类型时)。使用 ntext 数据类型时,offset 是在开始读取数据前跳过的字符数。使用 text 或 image 数据类型时,offset 是在开始读取数据前跳过的字节数。

size

是要读取数据的字节数(使用 text 或 image 数据类型时)或字符数(使用 ntext 数据类型时)。如果 size 是 0,则表示读取了 4 KB 字节的数据。

HOLDLOCK

使文本值一直锁定到事务结束。其他用户可以读取该值,但是不能对其进行修改。

注释
使用 TEXTPTR 函数获得有效的 text_ptr 值。如果返回不止一行,TEXTPTR 将返回指向指定行中的 text、ntext 或 image 列的指针,或返回指向查询所返回的最后一行中的 text、ntext 或 image 列的指针。由于 TEXTPTR 返回 16 字节的二进制字符串,所以最好声明一个控制文本指针的局部变量,然后在 READTEXT 中使用该变量。有关声明局部变量的更多信息,请参见 DECLARE @local_variable。

示例
下例读取 pub_info 表中 pr_info 列的第 2 个至第 26 个字符。

USE pubs
GO
DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(pr_info)
FROM pub_info pr INNER JOIN publishers p
ON pr.pub_id = p.pub_id
AND p.pub_name = 'New Moon Books'
READTEXT pub_info.pr_info @ptrval 1 25
GO

tom255 2001-05-22
  • 打赏
  • 举报
回复
用readtext

---------------------------------
READTEXT { table.column text_ptr offset size } [ HOLDLOCK ]

Arguments
table.column

Is the name of a table and column from which to read. Table and column names must conform to the rules for identifiers. Specifying the table and column names is required; however, specifying the database name and owner names is optional.

text_ptr

Is a valid text pointer. text_ptr must be binary(16).

offset

Is the number of bytes (when using the text or image data types) or characters (when using the ntext data type) to skip before starting to read the text, image, or ntext data. When using ntext data type, offset is the number of characters to skip before starting to read the data. When using text or image data types, offset is the number of bytes to skip before starting to read the data.

size

Is the number of bytes (when using the text or image data types) or characters (when using the ntext data type) of data to read. If size is 0, 4 KB bytes of data are read.

HOLDLOCK

Causes the text value to be locked for reads until the end of the transaction. Other users can read the value, but they cannot modify it.


---------------------------------

DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(pr_info)
FROM pub_info pr INNER JOIN publishers p
ON pr.pub_id = p.pub_id
AND p.pub_name = 'New Moon Books'
READTEXT pub_info.pr_info @ptrval 1 25
ttyp 2001-05-22
  • 打赏
  • 举报
回复
没人知道吗

7,765

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧