How to add some attributes when I use For Xml Path?
As I developed the sql statement using For Xml Path, the users now required
add new attributes to some tags.
For Example:
SQL:
Select TOP 2 Code, Name From City For Xml Path('City')
<City>
<Code>1</Code>
<Name>STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name>LEXINGTON, GA</Name>
</City>
The new requirement and expected result as:
<City>
<Code>1</Code>
<Name Changed="N">STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name Changed="N">LEXINGTON, GA</Name>
</City>
Select TOP 2 Code, 'N' as "Name/@.Changed", Name From City For Xml
Path('City')
Showing posts with label pathas. Show all posts
Showing posts with label pathas. Show all posts
Monday, March 19, 2012
How to add some attributes when I use For Xml Path?
How to add some attributes when I use For Xml Path?
As I developed the sql statement using For Xml Path, the users now required
add new attributes to some tags.
For Example:
SQL:
Select TOP 2 Code, Name From City For Xml Path('City')
<City>
<Code>1</Code>
<Name>STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name>LEXINGTON, GA</Name>
</City>
The new requirement and expected result as:
<City>
<Code>1</Code>
<Name Changed="N">STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name Changed="N">LEXINGTON, GA</Name>
</City>Select TOP 2 Code, 'N' as "Name/@.Changed", Name From City For Xml
Path('City')
As I developed the sql statement using For Xml Path, the users now required
add new attributes to some tags.
For Example:
SQL:
Select TOP 2 Code, Name From City For Xml Path('City')
<City>
<Code>1</Code>
<Name>STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name>LEXINGTON, GA</Name>
</City>
The new requirement and expected result as:
<City>
<Code>1</Code>
<Name Changed="N">STREATOR, IL</Name>
</City>
<City>
<Code>2</Code>
<Name Changed="N">LEXINGTON, GA</Name>
</City>Select TOP 2 Code, 'N' as "Name/@.Changed", Name From City For Xml
Path('City')
Subscribe to:
Posts (Atom)