hi
I want to select all the dates between 2 dates.ie if i'm passing 17th June and 19th june then it shud give 17,18 and 19.
Like wise if i'm giving 28th june and 3rd july it shud return 28,29,30,1,2,3.
Pls help me.
Thnx in advance
Nebubetween '20040101' and ''20040102
Showing posts with label passing. Show all posts
Showing posts with label passing. Show all posts
Friday, February 17, 2012
Extracting Attribute Values from XML Using XQuery
I am serializing a .NET object as XML and passing it as a parameter to a stored procedure. I am new to XQuery and have tried other places to find the answer to this question but have so far been unsuccessful.
How can I get the value of an attribute out of an XML document as a standard SQL Server data type? For instance, if my XML document were:
<RootNode>
<Object ID = "1234">
<AnElement>Some Other Value</AnElement>
</Object>
</RootNode>
What would be the correct XQuery to get the value of the ID attribute in the Object element?
Thanks in advance.
Kevin J Lambert
create table #xml_temp (
xml_col xml
)
insert into #xml_temp values('<RootNode>
<Object ID = "1234">
<AnElement>Some Other Value</AnElement>
</Object>
</RootNode>')
--With query() function
select xml_col.query('data(/RootNode/Object/@.ID)') from #xml_temp
--With value() function
select xml_col.value('data(/RootNode/Object/@.ID)[1]','int') from #xml_temp
Subscribe to:
Posts (Atom)