March 3, 2004 at 2:58 am
Hi, friends
I have the following problem:
I want to read a field of type TEXT and memorize its value into a variable
T-SQL.
For example, into my code I want to write:
...............
DECLARE @Variable_Name tipe (???)
SELECT @Variable_Name = Field
FROM Table_Name
WHERE .......
.................
The type of Field is TEXT.
Is it possible?
Anybody can help me??
Thanks !!
March 3, 2004 at 3:02 am
Take a look at READTEXT in BOL, although I doubt this will get you much further.
There is no *text* variable in T-SQL. Your best bet is varchar(8000). I guess your data is longer than 8,000 characters?
What do you want this for?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 3, 2004 at 3:29 am
Hi Frank,
Into Query Analyzer, I create this code (for example)
DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(Field)
FROM Table_Name
WHERE Id_Identificator = 3
READTEXT Table_Name.Field @ptrval 1 25
This code, it's OK!
But, my problem is to memorize the value of Field into a variable, for example
into a variable of type VARCHAR(8000), it's ok.
Is it possible
Thanks
Flavio
March 3, 2004 at 3:51 am
DECLARE @text_var varchar(8000)
SELECT @text_var = MsgNoteText
FROM mails_header
WHERE MsgID =
'0000000052473604077444499F10F4A2A11C085E0700EE482D8B9388E841ADE11B0CF1FA
A1DC0000008750640000EE482D8B9388E841ADE11B0CF1FAA1DC000000A438B30000'
SELECT LEFT(@text_var,20)
--------------------
<<a class ="frank"
(1 row(s) affected)
I wrapped the MsgID for readability. The original text is 30,270 characters long and therefore truncated after 8,000.
If that's no problem, this might be a solution.
Sorry, the software here interprets the hyperlink behind in my code. It should read < < a class ="frank"
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
March 3, 2004 at 6:11 am
Hi Frank, thanks,
but, I'm sorry, I don't understand !
What is the table mails_header ?
and the filed MsgID = '0000000005247....' why this value ?
Sorry
Flavio
March 3, 2004 at 6:18 am
Sorry, this is a real world example from one of my tables.
Replace with your table name and with your PrimaryKey or Unique Identifier.
HTH
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply