Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I have the following trim statement(right(rtrim([RSA_Record_Key_String]),len(reverse(substring(reverse(rtrim([RSA_Record_Key_String])),(0),charindex('-',reverse(rtrim([RSA_Record_Key_String]))))))))However some of the records don't have a - in them and just contain charactors. These records return no value How can I modify this so that it will always return a value?Example:1-abc-23 returns 231-abc Returns abc1 is not returning anything right now and I would like it to return 1
James K
Master Smack Fu Yak Hacker
3873 Posts
Posted - 2013-05-31 : 11:47:58
You have to do something so the substring function gets valid arguments. Following is shorter and may be sufficient:
http://visakhm.blogspot.in/2013/05/get-nth-positioned-string-from.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2013-06-02 : 13:00:20
Note that rtrim and ltrim are functions and not statements.MadhivananFailing to plan is Planning to fail