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 |
satheesh
Posting Yak Master
152 Posts |
Posted - 2014-06-17 : 10:46:42
|
Hi I have field 'Destination' as below Destination >\nDestination: AreaTwo<br />\n<br />\n------<br />\n*Found Re26<br />\nDestination: AreaOne<br />\n<br />\n------<br />\n*F/>\nDestination: AreaTwo<br />\n<br />\n------<br />\n*Found RI have to remove all character before 'Destination:' and after '<br />\n'i.e i need output like belowDestinationAreaTwoAreaOneAreaTwoHow to remove these character. Any help will be highly appreciated.ThanksRegards,SG |
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2014-06-17 : 11:35:14
|
[code]WITH StartStrAS( SELECT SUBSTRING(Destination, CHARINDEX('Destination:', Destination) + 13, 255) AS Destination FROM YourTable)SELECT LEFT(Destination, CHARINDEX('<br />\n', Destination) -1) AS DestinationFROM StartStr;[/code] |
|
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-06-17 : 11:57:12
|
Select Substring(yourfield,4,11) as n1, Substring(yourfield, 17, 7) as n2, Substring(yourfield, 88, 7) as n3, Substring(yourfield, 146,7) as n4 From dbo.YourTableWe are the creators of our own reality! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-06-21 : 05:22:55
|
[code]SELECT STUFF(LEFT(Destination, CHARINDEX('<br />\n', Destination + '<br />\n') -1),1,CHARINDEX('Destination:',Destination)+13,'') AS DestinationFROM StartStr[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|