Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jet_black
Starting Member
4 Posts |
Posted - 2009-02-05 : 17:18:38
|
| I am trying to take the end of a text string in a table and append it to the beginning of the same text string.Example:TEXT MORETEXT 123456I want:123456 TEXT MORETEXTWhat functions/syntax should I be exploring here for this task?Thanks for any assistance! |
|
|
jet_black
Starting Member
4 Posts |
Posted - 2009-02-05 : 17:36:03
|
| I got it, here it is for reference:SELECT RIGHT(COL1, 6) + ' ' + LEFT(COL1, ((len(COL1))-7))FROM TABLE1 |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-05 : 17:40:34
|
| Is data going to be consistent? |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-05 : 23:48:40
|
| if ur data will be 'TEXT MORETEXT 12345632' like this ur query will not works fineso u thisselect right(col1,charindex(' ',reverse(col1),1)-1) +' '+LEFT(col1, len(col1)-charindex(' ',reverse(col1),1)) |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-05 : 23:52:26
|
| Try this DEclare @var VARCHAR(32)set @var = 'TEXT MORETEXT 123456'select parsename(replace(@var,' ','.'),1)+' '+parsename(replace(@var,' ','.'),3)+' '+parsename(replace(@var,' ','.'),2) |
 |
|
|
|
|
|
|
|