all groups > sql server programming > may 2006 >
You're in the

sql server programming

group:

using text


Re: using text Adam Machanic
5/15/2006 2:17:01 PM
sql server programming:
You're going to have to get comfortable with the UPDATETEXT function, which
is somewhat painful to work with. Here's a sample from Nigel Rivett:

http://www.nigelrivett.net/SQLTsql/ReplaceText2.html

Note, SQL Server 2005 has a new datatype called VARCHAR(MAX) which makes all
of this much easier.


--
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--


[quoted text, click to view]

using text Roy Goldhammer
5/15/2006 8:59:16 PM
Hello there

I need to build T-sql update parse dinamicly which can be more then 8000
characters.

I can't (as far as i know) use text as varient, i can't concarent another
text to it, and so on

here is somthing i tried to run:
create table Test (
id int identity(1,1) primary key clustered
, txt text)

insert Test
VALUES ('Absolute position')

update Test
SET txt = txt + ', Bandwith'

and got an error:
Server: Msg 403, Level 16, State 1, Line 1
Invalid operator for data type. Operator equals add, type equals text.

how can i work with text field?

Re: using text Erland Sommarskog
5/15/2006 10:26:46 PM
Roy Goldhammer (roy@hotmail.com) writes:
[quoted text, click to view]

You can't.

The technique to use when working with very long strings for dynamic
SQL is to use @sql1, @sql2 etc and say:

EXEC(@sql1 + @sql2 + ...)


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
Re: using text Aaron Bertrand [SQL Server MVP]
5/15/2006 11:18:31 PM
[quoted text, click to view]

That depends, do you know how big your string might be? My suggestion would
be to break into chunks of 8000 and execute them together using separate
variables, like Erlan already described.

EXEC(@VariableWithFirst8000Chars + @VariableWithNext8000Chars + /*... + */
@VariableWithLast8000Chars);

Or, explain the actual problem and we can come up with a better solution.
The best answer is rarely a temp table and dynamic SQL.

Re: using text Roy Goldhammer
5/15/2006 11:50:51 PM
Thanks adam.

It was good for the first part, to concatent strings to the text, On the
temp table i also places string for determing the size of the text to make
it use for the future

now i need to execute the text.

I tried to use Execute but i couldn't. so far i use exec by getting the
string to varchar(8000) and run it by: exec(@str)

This options cannot be done on text. so how can i execute the data on text
field?


[quoted text, click to view]

Re: using text Roy Goldhammer
5/16/2006 12:00:00 AM
Whell Arnon:

I use temp table with 3 fields (id identity primary key clustered, txt Text,
tsize int)
If you can see, on any stinrg i concatent to txt using UPDATETEXT method, i
add the size of the current the text i add to tsize field. by that i always
know that is my text size.

As I explain before, the txt field will provide huge update parse with huge
condition which is being built dinamicly by some of my store procedures.

it will look like this:
Update tbl set fld = value from (huge join) where (huge where). this take
mutch more then 8000 characters.

After i build the text by concatent sgrings, i need to run the entire text.

So how can i do it with text?

can you help me on it?

[quoted text, click to view]

AddThis Social Bookmark Button