Results 1 to 2 of 2

Thread: openxml query help

  1. #1
    waqishah is offline Junior Member
    Last Online
    27th May 2014 @ 06:09 PM
    Join Date
    08 May 2009
    Age
    38
    Posts
    15
    Threads
    3
    Credits
    0
    Thanked
    0

    Default openxml query help

    declare @idoc int
    declare @doc char(8000)
    set @doc= '<SchoolRecord>
    <School ID="1" Name="A1">
    <Location ID="1" City="Karachi" Country = "Pakistan">
    <Area ID="1" Type="Primary" NoOfStudent="300">
    <Student ID="1" Name="Kashif" FatherName="Alam" />
    <Student ID="2" Name="Kamran" FatherName="Alam" />
    <Student ID="3" Name="Mujahid" FatherName="Hasan" />
    <Student ID="4" Name="Ishfaaq" FatherName="Hussain" />
    </Area>
    <Area ID="2" Type="Secondary" NoOfStudent="100">
    <Student ID="5" Name="Atif" FatherName="Alam" />
    <Student ID="6" Name="Amir" FatherName="Alam" />
    <Student ID="7" Name="Rehan" FatherName="Tariq" />
    <Student ID="8" Name="Jamil" FatherName="Muhammad" />
    </Area>
    </Location>
    <Location ID="2" City="Lahore" Country = "Pakistan">
    <Area ID="3" Type="Primary" NoOfStudent="200">
    <Student ID="9" Name="Owais" FatherName="Ali" />
    <Student ID="10" Name="Ibrahim" FatherName="Muhammad" />
    <Student ID="11" Name="Adam" FatherName="Khan" />
    <Student ID="12" Name="Ismayil" FatherName="Sheikh" />
    </Area>
    <Area ID="4" Type="Secondary" NoOfStudent="70">
    <Student ID="13" Name="Yousuf" FatherName="Nawaz" />
    <Student ID="14" Name="Hannan" FatherName="Baksh" />
    <Student ID="15" Name="Ishaq" FatherName="Ali" />
    <Student ID="16" Name="Talha" FatherName="Jamil" />
    </Area>
    </Location>
    </School>
    <School ID="2" Name="A2">
    <Location ID="3" City="Riyadh" Country = "SaudiArabia">
    <Area ID="5" Type="Primary" NoOfStudent="100">
    <Student ID="17" Name="Umer" FatherName="Hantool" />
    <Student ID="18" Name="Saud" FatherName="Herabi" />
    <Student ID="19" Name="Khalid" FatherName="Shawan" />
    <Student ID="20" Name="Muhammad" FatherName="Zharani" />
    </Area>
    <Area ID="6" Type="Secondary" NoOfStudent="50">
    <Student ID="21" Name="Faisal" FatherName="Riaz" />
    <Student ID="22" Name="Aaiz" FatherName="Kazran" />
    <Student ID="23" Name="Fahad" FatherName="Talabi" />
    <Student ID="24" Name="Homoud" FatherName="Alfaiz" />
    </Area>
    </Location>
    <Location ID="4" City="Dubai" Country = "Emirates">
    <Area ID="7" Type="Primary" NoOfStudent="900">
    <Student ID="25" Name="Owais" FatherName="Qerni" />
    <Student ID="26" Name="Ibrahim" FatherName="Asfiyan" />
    <Student ID="27" Name="Faizan" FatherName="Ahsan" />
    <Student ID="28" Name="Safan" FatherName="Ahsan" />
    </Area>
    <Area ID="8" Type="Secondary" NoOfStudent="500">
    <Student ID="29" Name="Fawad" FatherName="Hussain" />
    <Student ID="30" Name="Tuaha" FatherName="Syed" />
    <Student ID="31" Name="Umer" FatherName="Hamayun" />
    <Student ID="32" Name="Tariq" FatherName="Aslam" />
    </Area>
    </Location>
    </School>
    </SchoolRecord>'
    exec sp_xml_preparedocument @idoc OUTPUT, @doc

    select ID,Name,School FROM
    openxml (@idoc,'/SchoolRecord/School/Location/Area/Student',3)
    with (
    ID int'@ID',
    Name varchar(30)'@Name',
    School varchar(30)'../../../@Name'
    )


    " i need to get the results where location is of karachi only"
    i am feeling difficulty in maiking query with 'where' clause in open xml. kindly help me and do post me the reply at my email id given below.

    syedwaqihaider
    @yahoo

    thanx a lot

  2. #2
    Ghalib Awan's Avatar
    Ghalib Awan is offline Advance Member
    Last Online
    14th February 2022 @ 02:55 AM
    Join Date
    01 Feb 2010
    Location
    Hong Kong
    Age
    35
    Gender
    Male
    Posts
    6,672
    Threads
    187
    Credits
    86
    Thanked
    789

    Default

    Mein aap ko SQL ki query bata sakta hoon.

Similar Threads

  1. uc handler front query
    By Rajput-1 in forum Mobile phones problems and Help Zone
    Replies: 4
    Last Post: 6th June 2015, 04:06 PM
  2. SQL Query
    By MindHunter in forum Ask an Expert
    Replies: 3
    Last Post: 19th February 2015, 05:06 PM
  3. Query about brand
    By faraz_shaikh in forum Ask an Expert
    Replies: 4
    Last Post: 13th August 2012, 11:20 PM
  4. qUERY
    By mukslymeen in forum Introduction
    Replies: 5
    Last Post: 26th February 2010, 11:03 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •