Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update only a particular position in a field 1

Status
Not open for further replies.

storm75m

Programmer
Apr 18, 2001
81
US
I need the SQL syntax of how to update only the 25th position within a particular field. For example, I have a text field named USDATA in table named UBUCTL with data like this:

" Y YY N YYY NN 000000000 YN"

and I need to place an "N" in the 25th position of every record, but leave the rest of the data unchanged. I would like to be able to do this with one simple SQL statement instead of using code to loop through records. Any help would be much appreciated, code samples would be awesome. Thanks geniuses!
 
First run a Select query and see if you get the information you need:
Code:
SELECT FieldName, mid(FieldName, 1, 24) & 'N' & mid(FieldName, 26, len(FieldName)) As NewValue From TableName
if that gives you the correct information, you can use this update query:
Code:
Update tblName Set FieldName = mid(FieldName, 1, 24) & 'N' & mid(FieldName, 26, len(FieldName)

Leslie
 
missing a paren:

Code:
Update tblName Set FieldName = mid(FieldName, 1, 24) & 'N' & mid(FieldName, 26, len(FieldName))

Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top