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 |
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2009-07-20 : 07:11:50
|
| Hi I need to replace a text field called "desc" with itself minus the last four characters. Somebody has run a process which puts a rude word on the end of the decsriptionsthanks ps its sql server 2000 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-07-20 : 07:15:37
|
[code]update tset desc = left(t.desc, len(t.desc) - 4)from yourtable t[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2009-07-20 : 07:23:48
|
| Sorry it's a memo field - i forgot to sayServer: Msg 8116, Level 16, State 2, Line 1Argument data type text is invalid for argument 1 of len function.Server: Msg 8116, Level 16, State 1, Line 1Argument data type text is invalid for argument 1 of left function. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-20 : 07:27:22
|
Replace LEN with DATALENGTH.And use SUBSTRING instead of LEN.SUBSTRING(Col1, 1, DATALENGTH(Col1) - 4) N 56°04'39.26"E 12°55'05.63" |
 |
|
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2009-07-20 : 07:40:20
|
| thanks a lot |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-20 : 08:05:30
|
quote: Originally posted by Peso And use SUBSTRING instead of LEN.
And use SUBSTRING instead of LEFT. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|