tsql - How to cut substring between known characters in SQL Server -
How do I cut the substrings between the two known character sequences in the SQL server?
For example: this is my string (column in a table)
'DateTime format = DDMM.AyyA and ReportData_FormatDate = 08/11/2014 00: 00 : 00 and ReportDataotAut = 08/12/2014 23:59: 00 & amp; Reports_Brand: isnull = true & amp; Reports_Portal: isnull = true & amp; Reports_Currency: isnull = true & amp; ReportBy = Week & amp; OrderBy: isnull = true & amp; IncludeDataForLastHour: isnull = True & amp; Server name: isnull = true & amp; User = pirman1 & amp; Reports_Export = False & amp; Internal '
and I should see only
pirman1 which is between
and user = and the following
& amp; .
I tested this code, with some changes in the code of Moorink, it's a fine job Does. Select
from REPLACE (Replus (SUBSTRING (string, start_pos, end_pos - start_pos +1), '& amp; user =', ''), '& amp;', '') (SELECT string, CHARINDEX ('& amp; user =', string) AS start_pos, CHARINDEX ('& amp;', string, CHARINDEX ('& user =', string) +1) AS
Comments
Post a Comment