Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-12-01 : 12:48:22
|
| Does anyone know anything about UPDATETEXT?Right now I have text that has quotes around it. I need to remove those, but it is in a Text field(which it is big enough where it needs to be).[code]DECLARE @ptrval binary(16)SELECT @ptrval = TEXTPTR(notes) FROM tblParadox UPDATETEXT tblParadox.notes @ptrval 1 '"' ''[code]Anyone know how to fix that so it will take out the quotes? Thanks!BrendaIf it weren't for you guys, where would I be? |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-01 : 15:02:28
|
| Break it up in to 8k chunks and use replaceOr do what I suggested beforeBrett8-) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-12-01 : 15:08:02
|
| I would use your other idea(thanks by the way), but i figured out how to insert it into 3 columns using the export/import wizard. How would I break it up in to 8000 bytes?BrendaIf it weren't for you guys, where would I be? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-01 : 15:37:28
|
You have to concat all of the substrings together in 1 shot. You didn't delete the data, you replaced with data starting from 8001 and on.More likely there was no data in those locations. except for a rare few rows.UPDATE myTable99 SET Col1 = REPLACE(SUBSTRING(Col1,1,8000),'x','a') + REPLACE(SUBSTRING(Col1,8001,8000),'y','a') WHERE pkCol = 1 GO Brett8-) |
 |
|
|
brendalisalowe
Constraint Violating Yak Guru
269 Posts |
Posted - 2004-12-01 : 16:05:48
|
| Everything works fine, except when I do this:update tblparadoxset notes = REPLACE(SUBSTRING(notes,8001,8000),'"','')When I do that, it deletes everything. Do you know why?BrendaIf it weren't for you guys, where would I be? |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-01 : 16:42:56
|
Damn, I did an edit instead of a reply...And I still think this is a bad idea. My guess is you can go up to 32k before you start needing to use READTEXT, UPDATETEXT and WRITETEXTThe original codeUSE NorthwindGOSET NOCOUNT ONCREATE TABLE myTable99(pkCol int, Col1 text)GODECLARE @x varchar(8000), @y varchar(8000)SELECT @x = REPLICATE('x',8000), @y = REPLICATE('y',8000)-- mimic the loadINSERT INTO myTable99(pkCol, Col1)SELECT 1, @x + @y--Update the DataUPDATE myTable99 SET Col1 = REPLACE(SUBSTRING(Col1,1,8000),'x','a') + REPLACE(SUBSTRING(Col1,8001,8000),'y','a') WHERE pkCol = 1 GOSELECT * FROM myTable99GOSET NOCOUNT OFFDROP TABLE myTable99GOBrett8-) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-02 : 09:12:18
|
quote: Originally posted by brendalisalowe Everything works fine, except when I do this:update tblparadoxset notes = REPLACE(SUBSTRING(notes,8001,8000),'"','')When I do that, it deletes everything. Do you know why?BrendaIf it weren't for you guys, where would I be?
Yes, I do now...because I'm an idiot....See what not thoroughly testing does...Its seems that even though you concat any varchar values, your still limited to the max size of varchar(8000)For exampleUSE NorthwindGOSET NOCOUNT ONCREATE TABLE myTable99(pkCol int, Col1 text)GODECLARE @x varchar(8000), @y varchar(8000)SELECT @x = REPLICATE('x',8000), @y = REPLICATE('y',8000)-- mimic the loadINSERT INTO myTable99(pkCol, Col1)SELECT 1, @x + @y-- How long?SELECT LEN(@x+@y)SELECT DATALENGTH(Col1) FROM myTable99SELECT SUBSTRING(Col1,8001,1) FROM myTable99GOSET NOCOUNT OFFDROP TABLE myTable99GOI'm liking my idea of many rows even better...Brett8-) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-12-02 : 14:24:30
|
| What did you do?Modify the text file?Brett8-) |
 |
|
|
|
|
|
|
|