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 |
dahinda61428
Starting Member
2 Posts |
Posted - 2014-11-26 : 12:35:47
|
Hello,I have a field that is populated with a week number, a year and other characters. For example: OSF-2014-wk-15. I need to pull out the week number at the end of the string. The week number can be a two number week as above or a one number week such as OSF-2014-wk-6. I used the Right function, RIGHT(A.Week, 2), but that pulls in the dash if it is a one number week. How can I determine if it is a one number week or two and pull the appropriate number? I do not want the dash. Thank you for all your help! |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-11-26 : 12:40:48
|
select replace(right(yourcolumn, 2), '-', '')from yourtableTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
dahinda61428
Starting Member
2 Posts |
Posted - 2014-11-26 : 13:22:08
|
Thank you! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|