TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jaymin sathavara
NA
31
2.3k
Extracting string after and before a character '-' or '<'
Nov 24 2020 3:34 AM
Hello Everyone!!
Please Review Following table.
UDF_WorkLocation_6
-------------------------------------------------
MUMBAI - Maharastra<6>
AHMEDABAD - Gujarat<1>
MUMBAI - Maharastra<6>
CHANDIGARH - Chandigarh<34>
NULL
DELHI - Delhi<42>
NULL
INDORE - Madhya Pradesh<56>
Here it is column name 'UDF_WorkLocation_6' in table.I want split string from '-' then set into two columns And In second column Remove string after charter '<' using SQL Query. I want output in two columns as below.
Output Table
Column1
Column2
MUMBAI
Maharastra
AHMEDABAD
Gujarat
MUMBAI
Maharastra
CHANDIGARH
Chandigarh
NULL
NULL
DELHI
Delhi
NULL
NULL
Can anyone please help me?
What I have tried:
I have prepared query for split string.For instant, string is 'MUMBAI - Maharastra<6> '
and got output for second column like 'Maharastra<6>' using below sql query
SELECT LTRIM(SUBSTRING(AccountMasterUDF.UDF_WorkLocation_6, CHARINDEX('-', AccountMasterUDF.UDF_WorkLocation_6) + 2, 100))
But i also want two remove charters after '<' this.
Reply
Answers (
6
)
Issues with Dapper query syntax
Balance is not calculating correct ,if date filter is applied?