Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml column required columns within xml field

Status
Not open for further replies.

mauu

MIS
May 23, 2007
13
0
0
US
Say i have a table with an xml field. this xml field contains it's own pseudo table, so is there a way to force data entered into new records of the main table for this xml field to use the same structure? hmmm sounds confusing... example:
Code:
INSERT INTO email_column (xColumn) VALUES (
'<object type="view">
   <name>livefeed_unprocessed</name>
   <remote>1</remote>
   <provider>SQLNCLI</provider>
   <connectionstring>SERVER=tatooine.grscorp.com;Trusted_Connection=yes;</connectionstring>
   <database_name>OEN</database_name>
   <column>
      <column_name>clientkey_id</column_name>
	  <column_type>INT</column_type>
   </column>
   <column>
      <column_name>name</column_name>
	  <column_type>VARCHAR(50)</column_type>
   </column>
   <column>
      <column_name>qty</column_name>
	  <column_type>INT</column_type>
   </column>
   <column>
      <column_name>oldest_record</column_name>
	  <column_type>DATETIME</column_type>
   </column>
</object>')


CREATE PRIMARY XML INDEX idx_xColumns on email_column (xColumn)

CREATE XML INDEX idx_xColumn_Path on email_column (xColumn)
   USING XML INDEX idx_xColumns FOR PATH

CREATE XML INDEX idx_xColumn_Property on email_column (xColumn)
   USING XML INDEX idx_xColumns FOR PROPERTY

I'd like to force all records within the table "email_column" to use:

Code:
<object type="view">
   <name>livefeed_unprocessed</name>
   <remote>1</remote>
   <provider>SQLNCLI</provider>
   <connectionstring>SERVER=tatooine.grscorp.com;Trusted_Connection=yes;</connectionstring>
   <database_name>OEN</database_name>
   <column>
   </column>
</object>

of course the <column> part is optional and would very depending on number of columns in the view or stored proc.
 
I think the easiest way to do that is to validate the fields and add the appropriate tags with a server side language, i.e. ASP or ASP.NET or PHP.

[monkey][snake] <.
 
??? :p You're not speakin my language. :p

I'm not a programmer per say. I'm a dba that does all the database design work and stored proc creation for sql server, so it'd have to be something within sql server. Ie. I'm hopping there's a way to do something similar to "make it a required field" like you can with a sql table.

 
You can probably do it with a very large regular expression, but I'm not the person to answer that question.
[cry]

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top