Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update mutliple database string values
Message
 
To
24/08/2012 14:23:04
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01551325
Message ID:
01551335
Views:
51
>>I have a database that has following character string values:
>>
>>
>>"3440.01"
>>"3440.02"
>>...
>>...
>>"3440.99"
>>"3440.100"
>>"3440.101"
>>"3440.102"
>>"3440.103"
>>
>>
>>
>>how can I write a sql update statement that will change all the range values from "3440.01" to "3440.99" to new values of "4567.01" to "4567.99". And then the remaining range of values "3440.100" to "3440.103" to new range of values as "4569.100" to "4569.103"
>
>
>UPDATE YourTable ;
>   SET YourField = STRTRAN(YourField, "3440", "4567")  ;
>   WHERE LEFT(YourField) = "3440" ;
>         AND LEN(ALLTRIM(STREXTRACT(YourField, "."))) = 2
>
>UPDATE YourTable ;
>   SET YourField = STRTRAN(YourField, "3440", "4569")  ;
>   WHERE LEFT(YourField) = "3440" ;
>         AND LEN(ALLTRIM(STREXTRACT(YourField, "."))) = 3
>
>
>My guess is you don't want to be quite this specific, but this should give you some ideas.
>
>Tamar


Thank you Tamar. I have about 1000 item to change. Beats writing the following
x = '3470'
SCAN FOR employee.e_itemno = '3491'
	id = e_id
	dot_after = ALLTRIM(STUFF(e_itemno,1,4,""))
	new_itemno = x + dot_after
	UPDATE employee SET e_itemno = new_itemo where e_id = id	
ENDSCAN 
thanks again.
nick
Previous
Reply
Map
View

Click here to load this message in the networking platform