Given two tables:
T1( EntityID int , EmailAddress varchar(55),MaxNumberOfConnections int )
T2( EntityID int , EntityAttributes XML )
How do I insert all the data from T1 into T2 with a single statement in such a way that all the columns in T1 (all but EntityID ) are converted into one XML column in T2 :
T1( 1,'1234@1234.com',454)
T2(1, '<Attributes>
<Attribute EmailAddress="1234@1234.com">
<Attribute MaxNumberOfConnections ="454">
</Attributes>' )
Here are two solutions based upon my comment –
Single “Attribute” element with multiple attributes:
Individual element for each field: