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 7829563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:49:36+00:00 2026-06-02T10:49:36+00:00

My input is an XML column in SQL Server table like this: <word Entry=Ketab

  • 0

My input is an XML column in SQL Server table like this:

<word Entry="Ketab" Affix="miyanvand" Pos="esm" Derv="Jamed" />

Desired output: a table like this:

Entry    | Affix       | Pos     | Derv
Ketab    | miyanvand   | esm     | Jamed
  • 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-02T10:49:37+00:00Added an answer on June 2, 2026 at 10:49 am

    If you are using sql-server 2005+. Then maybe something like this:

    DECLARE @xml XML=
    '<word Entry="Ketab" Affix="miyanvand" Pos="esm" Derv="Jamed" />'
    
    SELECT 
       Y.ID.value('(@Entry)[1]', 'Varchar(100)') as [Entry],
       Y.ID.value('(@Affix)[1]', 'Varchar(100)') as [Affix],
       Y.ID.value('(@Pos)[1]', 'Varchar(100)') as [Pos],
       Y.ID.value('(@Derv)[1]', 'Varchar(100)') as [Derv]
    FROM @xml.nodes('/word') as Y(ID)
    

    Or you can also do it like this:

    DECLARE @xml XML=
    '<word Entry="Ketab" Affix="miyanvand" Pos="esm" Derv="Jamed" />'
    
    SELECT 
        @xml.value('(/word/@Entry)[1]', 'varchar(50)') as Entry,
        @xml.value('(/word/@Affix)[1]', 'varchar(50)') as Affix,
        @xml.value('(/word/@Pos)[1]', 'varchar(50)') as Pos,
        @xml.value('(/word/@Derv)[1]', 'varchar(50)') as Derv
    

    Or if you have a table. Then something like this:

    DECLARE @tbl TABLE(ID INT,someXML XML)
    INSERT INTO @tbl
    VALUES
        (1,'<word Entry="Ketab" Affix="miyanvand" Pos="esm" Derv="Jamed" />')
    
    SELECT
        tbl.ID,
        Y.ID.value('(@Entry)[1]', 'Varchar(100)') as [Entry],
        Y.ID.value('(@Affix)[1]', 'Varchar(100)') as [Affix],
        Y.ID.value('(@Pos)[1]', 'Varchar(100)') as [Pos],
        Y.ID.value('(@Derv)[1]', 'Varchar(100)') as [Derv]
    FROM
        @tbl AS tbl
        CROSS APPLY someXML.nodes('/word') as Y(ID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with the column's datatype as xml in SQL Server 2005.
The input XML tag must be validated for a pattern which is like this:
I want to create a neat two-columns input form like this: My xml layout
This is my input xml: <root> <node1/> <node2/> <node3/> <node4/> <othertags/> </root> The output
I have an XML structure like the following: <tables> <table name=tableName1> <row ID=34 col1=data
In SQL Server 2008, I have a scenario where I have a table with
I am creating a generic XML to SQL Server data driver (In c#), that
My sample input XML is: <root> <a> <b>item</b> <b>item1</b> <b>item2</b> <b>item3</b> <b>item4</b> </a> </root>
Given the input XML file: <acctInfo> <wfInfo> <aaa>1</aaa> <bbb>1</bbb> <ccc>1</ccc> <ddd>1</ddd> <eee>1</eee> </wfInfo> <acctInfo>
I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>

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.