Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:17:23+00:00 2026-06-01T13:17:23+00:00

I need to write a stored procedure for which the input is a string.

  • 0

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:

Name =Praveen | City=Hyderabad | Mobile=48629387429| Role=User| etc

In the stored procedure I have declared variables like @x, @y, @z, @t to obtain values as

@x=Praveen (Name value)
@y=Hyderabad (City Value)
@z=48629387429(Mobile Value)
@t=User(Role Value)

Also input string can have the values in any order like

City=Hyderabad | Mobile=48629387429 | Role=User | Name =Praveen |etc

Once I parse the values into @x, @y, @z, @t etc I have to use these values in the stored procedure.

Kindly let me how I can parse the input string to obtain the values of Name, City, Mobile, Role into @x, @y, @z and @t respectively.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:17:25+00:00Added an answer on June 1, 2026 at 1:17 pm

    One possible solution is use XML

    DECLARE @text VARCHAR(1000) 
            ,@xml xml
    
    SELECT @text = 'City=Hyderabad | Mobile=48629387429 | Role=User | Name =Praveen'
    
    SELECT @text = REPLACE(@text,'|','"')
        ,@text = REPLACE(@text,'=','="')
        ,@text = '<row ' + @text + '"/>'
    
    SELECT @xml = CAST(@text AS XML)
    
    select 
        line.col.value('@Name[1]', 'varchar(100)') AS Name
        ,line.col.value('@City[1]', 'varchar(100)') AS City
        ,line.col.value('@Mobile[1]', 'varchar(100)') AS Mobile 
        ,line.col.value('@Role[1]', 'varchar(100)') AS Role 
    FROM @xml.nodes('/row') AS line(col)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to write a stored procedure which will return a string.logic is when
I need a stored procedure which will allow me to return sorted results based
I need to create a stored procedure which will get destination IP and then
I'm using paging which uses a stored procedure to filter by letter. I need
I am trying to write a stored procedure which selects columns from a table
I need to write a stored procedure to update one of a set of
I need to write a Stored procedure in SQL server whose data returned will
I need to write a stored procedure to allow someone to search a db.
I need to write a stored procedure that will search a table based on
In Oracle PL/SQL I need to write a stored procedure that may throw a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.