
USE xmldb
GO

DROP TABLE xml_tab
GO

CREATE TABLE xml_tab(
  the_id INTEGER PRIMARY KEY IDENTITY,
  xml_col XML)
GO

INSERT xml_tab VALUES('<people><person name="curly"/></people>')
INSERT xml_tab VALUES('<people><person name="larry"/></people>')
INSERT xml_tab VALUES('<people><person name="moe"/></people>')
GO

SELECT the_id, 
  xml_col.value('/people[1]/person[1]/@name', 'varchar(50)') AS name 
  FROM xml_tab
GO

SELECT the_id  
  FROM xml_tab
  WHERE xml_col.value(
    '/people[1]/person[1]/@name', 'VARCHAR(50)') = 'curly'
GO
