Showing posts with label document. Show all posts
Showing posts with label document. Show all posts

Sunday, March 11, 2012

Access to TEXT column

Hi,

I have a table with a TEXT column and this column contains an XML document. I'm developing a TSQL stored procedure which reads the content of this column and accesses the values in the XML elements but I have a lot of problems...

1) How can I read the text column and store the value in a variable? I tried

declare @.a varchar(2048)
set @.a = (SELECT TEXT_COLUMN FROM MY_TABLE)

but it returns

Server: Msg 279, Level 16, State 3, Line 2
The text, ntext, and image data types are invalid in this subquery or aggregate expression.

I tried also with the READTEXT function but I just can't find how to store data read in a variable...

2) which length should I use for the VARCHAR variable which will store the data? Is it possible not to specify a length with SQL Server 7 or 2000?

Thanks!

Andrea

In SQL Server 7/2000 local variables cannot have a text data type. My advice would be if you know the length of the xml data is not going to be greater than 4000 chars (aprox.), use an NVARCHAR, that is going to allow you to be more flexible with your code.

Hope this helps,

Roberto Hernández-Pou
http://community.rhpconsulting.net

|||

you can try this

declare @.a varchar(8000)

set @.a = (SELECT convert(varchar(8000),text1) FROM texttest where text1like'some%' )

select @.a

You 'll be able to use text column in procedures but it has to converted to an accepted datatype in procedures

|||Just keep in mind that a decent sized XML document can easily go past 8000 characters causing any extra data to be truncated.|||

Hi,

thanks Gopi, Roberto and Whitney! Useful answers and comments!

Andrea

Tuesday, March 6, 2012

Access Text Within A SQL Binary Field

Is there any way to access the text within a SQL Binary object? For example
if I wanted to count the number of words within a Word document that had bee
n
added to a binary field in the database.
I figure the IFilters used by the Full-Text indexing service must do
something like this in order to create it's keyword index database.Look for: textptr, readtext, writetext, updatetext, textvalid and
sp_invalidate_textptr in the BOL.
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Anthony" <Anthony@.discussions.microsoft.com> wrote in message
news:3CFF2482-3A52-40E1-B629-3873ACAEDC41@.microsoft.com...
> Is there any way to access the text within a SQL Binary object? For
> example
> if I wanted to count the number of words within a Word document that had
> been
> added to a binary field in the database.
> I figure the IFilters used by the Full-Text indexing service must do
> something like this in order to create it's keyword index database.|||Anthony,
Out-of-the box with either SQL Server 2000 or SQL Server 2005 (Yukon) this
is not possible. You would need to either parse the text of the MS Word
documents before you inserted the documents into an IMAGE datatype or write
your own IFilter *wrapper* to capture the text into a separate text based
column. The MSDN Platform SDK has code examples and utilities that can be
used to the later, if you want to do this.
Yes, you are correct, that is what the IFilters (Microsoft's and 3rd party)
do.
Regards,
John
--
SQL Full Text Search Blog
http://spaces.msn.com/members/jtkane/
"Anthony" <Anthony@.discussions.microsoft.com> wrote in message
news:3CFF2482-3A52-40E1-B629-3873ACAEDC41@.microsoft.com...
> Is there any way to access the text within a SQL Binary object? For
> example
> if I wanted to count the number of words within a Word document that had
> been
> added to a binary field in the database.
> I figure the IFilters used by the Full-Text indexing service must do
> something like this in order to create it's keyword index database.