Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: replacing characters using UPDATE statement


Message #1 by "attila" <a.balog@d...> on Fri, 25 Jan 2002 14:10:41
Maybe this might work:

UPDATE customers
SET Zipcode = 
     Left(Zipcode, 2) + Right(Zipcode, 1) + Substring(Zipcode, 3,3)

maybe this is what you already tried?
If this doesn't work, maybe add a column of NULLs and update them with 
this info. Such as:

SELECT Name, Address, Null AS Zipcode
INTO #Temp
From customers


UPDATE #Temp
SET #Temp.Zipcode = 
     Left(Customers.Zipcode, 2) + Right(Customers.Zipcode, 1) 
          + Substring(Customers.Zipcode, 3,3)
From Customers


Yet a third possibility is using a cursor to step through the table and 
change each one with a similar statement.

Hope this helps
Bill
William.Markham@P...



  Return to Index