I need to write a stored procedure for which the input is a string.
The input string contains variable names and their values separated by pipeline delimiter like this:<
Let's assume your input param is called @Text.
DECLARE @Text varchar(255),
@x varchar(255)
SET @Text = 'Name=Praveen | City=Hyderabad | Mobile=48629387429| Role=User'
-- Added to show how to account for non-trailing |
SET @Text = @Text + ' | ';
SET @x = LTRIM(RTRIM(substring(
@Text,
charindex('Name=', @Text) + LEN('Name='),
charindex(' | ', @Text, charindex('Name=', @Text)) - LEN('Name=')
)))
SELECT @x
Then just repeat this for @y, @z, @t change Name= to whatever your break is.