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.