Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XML General > SQL and XML

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2008, 07:24 PM
Andy B
 
Posts: n/a

Default Using xml attribute in the where clause of a slect statement.



I have the following select/insert statement:

insert into [News].[NewsArchive] select [Article], [LastModified] from
[News].[News] where ...

In the where clause, I need to use the value of the attribute
/NewsArticle/@Date in an xpath statement. How do you do this?


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-18-2008, 01:45 PM
Martin Honnen
 
Posts: n/a

Default Re: Using xml attribute in the where clause of a slect statement.

Andy B wrote:
> I have the following select/insert statement:
>
> insert into [News].[NewsArchive] select [Article], [LastModified] from
> [News].[News] where ...
>
> In the where clause, I need to use the value of the attribute
> /NewsArticle/@Date in an xpath statement. How do you do this?


Example
WHERE xmlColumnName.value('(/NewsArticle/@Date)[1]', 'datetime') =
'2008-10-18T12:00:00'

That assumes (based on the attribute name) that the Date attribute
contains a date/time value that you want to cast to an SQL Server
datetime value for instance.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 12:05 PM.
Style Developed by Epic Designz