0

I have a string like

https:\/\/www.abc.ca\/v3\/homes\/190135717\/responses\/bulk?page=5&per_page=100

I want everything after the equal sign = and before &, i.e the number 5 in SQL Server

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
vani malge
  • 85
  • 1
  • 6
  • 1
    Have you looked at built-in functions in SQL Server like [`CHARINDEX`](https://learn.microsoft.com/en-us/sql/t-sql/functions/charindex-transact-sql) and [`SUBSTRING`](https://learn.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql)? What have you tried? – Aaron Bertrand Aug 17 '20 at 15:26
  • 1
    A simple Google search produces [this SQL function you could use](http://www.sql-server-helper.com/tips/tip-of-the-day.aspx?tkey=535E4591-CF78-4469-814C-B43291542B4B&tkw=query-string-parser-function). Have you tried something along those lines? – strickt01 Aug 17 '20 at 15:36

1 Answers1

0

Try this below logic using SUBSTRING and CHARINDEX:

Demo Here

DECLARE @T VARCHAR(200) = 'https:\/\/www.abc.ca\/v3\/homes\/190135717\/responses\/bulk?page=5&per_page=100'

SELECT SUBSTRING(@T,CHARINDEX('=',@T,0)+1,CHARINDEX('&',@T,0)-CHARINDEX('=',@T,0)-1)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
mkRabbani
  • 16,295
  • 2
  • 15
  • 24