Truncate String field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a string field. This unwanted chars only appears once in a while.
EXHAUST trade123456
EXHAUST trade789012
EXHAUST trade345678
EXHAUST trade901234

I want to truncate the frist 13 charctors "EXHAUST trade" without creating
new column.

Any hints for an update query.

Thank you,
Hitesh
 
try

UPDATE TableName SET FieldName = IIf([TableName].[FieldName] Like
"E*",Right([TableName].[FieldName],6),[TableName].[FieldName]);

note that when running an update query for the first time, it's always
advisable to try it on a COPY of your database; if the update doesn't turn
out as expected, ditch the copy and try again on another COPY of the
db...until you get it working.

hth
 
Hitesh said:
I have a string field. This unwanted chars only appears once in a while.
EXHAUST trade123456
EXHAUST trade789012
EXHAUST trade345678
EXHAUST trade901234

I want to truncate the frist 13 charctors "EXHAUST trade" without creating
new column.


Use a calculated field in your query:

IIf(thefield Like "EXHAUST trade*", Mid(thefield,14),
thefield)
 
Hi,

I have a string field. This unwanted chars only appears once in a while.
EXHAUST trade123456
EXHAUST trade789012
EXHAUST trade345678
EXHAUST trade901234

I want to truncate the frist 13 charctors "EXHAUST trade" without creating
new column.

Any hints for an update query.

Yet a third option:

UPDATE fieldname
SET fieldname = Replace([fieldname], "EXHAUST trade", "")
WHERE fieldname LIKE "EXHAUST trade*";


John W. Vinson[MVP]
 
Thank you everyone. It worked!!
SET fieldname = Replace([fieldname], "EXHAUST trade", "")
WHERE fieldname LIKE "EXHAUST trade*";

I going with this one... but other two solutions worked too.

Hitesh


John said:
Hi,

I have a string field. This unwanted chars only appears once in a while.
EXHAUST trade123456
EXHAUST trade789012
EXHAUST trade345678
EXHAUST trade901234

I want to truncate the frist 13 charctors "EXHAUST trade" without creating
new column.

Any hints for an update query.

Yet a third option:

UPDATE fieldname
SET fieldname = Replace([fieldname], "EXHAUST trade", "")
WHERE fieldname LIKE "EXHAUST trade*";


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top