SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Move first 4 characters to the end in a field?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

taunt
Posting Yak Master

116 Posts

Posted - 07/02/2013 :  17:57:15  Show Profile  Reply with Quote
Hello I have a table items and a column named itemname the I need to move the first 5 characters to the end, but not all the fields are the same length. Some look like this VOL.3-VARIOUS and some look like this VOL.5-VARIOUS-NAME. How can I get it to move the first 5 charaters to the end so they would all be the same like this VARIOUS-VOL.3 and VARIOUS-NAME-VOL.5. Do I use SUBSTRING(itemname, 1, 5) with other commands?

SwePeso
Patron Saint of Lost Yaks

Sweden
30265 Posts

Posted - 07/02/2013 :  19:49:08  Show Profile  Visit SwePeso's Homepage  Reply with Quote
UPDATE dbo.Table1 SET Col1 = SUBSTRING(Col1, 7, LEN(Col1)) + '-' + LEFT(Col1, 5) WHERE Col1 LIKE 'VOL.[0-9]-%';





N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000