I am very new to this, but I am trying to create some xml using t-sql in MSSQL 2005. I am doing OK but have hit a problem. I don't know how to set an atribute and a for a node. I can do one or the other but not both! Here is what I have so far:

Code:
SELECT
	 '12' AS '@id',
	 'en-gb' AS '@lang',
	 'Beta' AS 'name',(
		SELECT NULL,(
			SELECT
			 ID AS '@id',
			 Name AS 'name',(
				SELECT NULL,(
					SELECT 
					 'email' AS '@type',
                                      Email AS 'contact'
					FOR XML PATH('contact'), TYPE	
				)
				FOR XML PATH('contact-details'),TYPE
			)
			FROM myview
			FOR XML PATH('team'),TYPE
		)
		FOR XML PATH('teams'),TYPE
	 )
	 FOR XML PATH('overview'),TYPE
The problem is the email bit. I need <contact type='email'>emailfromquery</contact> - but I can't get this (the above just creates a child 'contact' node - if i leave it out it creates a child node of the same name as the value (Email)). How do I do this?

Please critique any other bits which I am soing wrong as well - any advice greatfully received.

cheers

monkey