DECLARE @text_value binary(16) SELECT @text_value = TEXTPTR(C_text) FROM MyTable1 WHERE MyId=25
示例 下例读取 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
if exists(select name from sysobjects where name='t1' and type='u') drop table t1 go create table t1(c1 int,c2 text) insert t1 values(1,'This is a text.') go declare @Str varbinary(16) select @Str=textptr(c2) from t1 where c1=1 readtext t1.c2 @Str 0 15 go
select @Str=sdf from TABLE1
print @Str
所以楼上两位非正解
SELECT @text_value = TEXTPTR(C_text)
FROM MyTable1 WHERE MyId=25
下例读取 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
drop table t1
go
create table t1(c1 int,c2 text)
insert t1 values(1,'This is a text.')
go
declare @Str varbinary(16)
select @Str=textptr(c2) from t1
where c1=1
readtext t1.c2 @Str 0 15
go