Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Rosstacular
Starting Member
2 Posts |
Posted - 2010-07-16 : 09:46:04
|
| [code]SELECT -- <select>( SELECT -- <option> '' AS [@value], ' Choose a something ' AS [text()] UNION ALL SELECT cast(something AS varchar(10)) AS [@value], RTRIM([something ]) AS [text()] FROM something ORDER BY [something] FOR XML PATH('option'), TYPE)FOR XML PATH(''), ROOT('select')[/code]Throws the following error: "The FOR XML clause is invalid in views, inline functions, derived tables, and subqueries when they contain a set operator. To work around, wrap the SELECT containing a set operator using derived table syntax and apply FOR XML on top of it."When I take out one of the unions it works. Thanks in advance for your help. |
|
|
Rosstacular
Starting Member
2 Posts |
Posted - 2010-07-16 : 10:29:18
|
| So I just used one Select (root node) and instead of for "xml path option, type" I did "AS [option] and its wurks. Thx for nothin. Lol jks. <3 |
 |
|
|
|
|
|