Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Posting Yak Master

128 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?

Patron Saint of Lost Yaks

30421 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  
 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.02 seconds. Powered By: Snitz Forums 2000