How can I use replace statement in SQL query to replace/remove all the text inside the square bracket and the square bracket itself. I have many similar text like that with square bracket in my database, can I use regular expression or something similar?
Solution :
declare @str varchar(100)
select @str='This is Sql testing Text [23/10/2018 12:23 - admin]'
select stuff(@str,patindex('%(%',replace(@str,'[','(')),LEN(@str),'')
Result : This is testing Text
Solution :
declare @str varchar(100)
select @str='This is Sql testing Text [23/10/2018 12:23 - admin]'
select stuff(@str,patindex('%(%',replace(@str,'[','(')),LEN(@str),'')
Result : This is testing Text
No comments:
Post a Comment