Friday, March 30, 2012
Proprties not imported with Table
Look at DTS transfer Database Task option
Or better yet, script the objects then build them...I prefer this method, and use bcp|||Originally posted by joejcheng
If you use DTS, make usre you use the Copy object(s) instead of Copy table(s) option.
The copy object worked ... Thanks
Wednesday, March 28, 2012
Propogation of Null
from the total. I have the expression...
=SUM(Fields!IncludeInTotal.Value * Fields!AtoC.Value)
...where IncludeInTotal is integer value 1 or 0 and AtoC is numeric but
possibly null.
I was expecting a lot of blank cells on my output but instead got lots of
zeros. It seems that when AtoC is null the result of 1*AtoC isn't null but is
zero.
I've recoded to use...
=SUM(Iif( IsNothing(Fields!AtoC.Value) OrElse Fields!IncludeInTotal = 0,
Nothing, Fields!AtoC.Value )
I was very surprised by this behaviour (2005sp2) as I would've expected it
to behave like SQLServer and the null to propogate.
Is this by design? Is there a property against the report that sets this
behaviour as opposed to propogating nulls?
AndrewHello Andrew,
I got some confusion. Since you are using the SUM function, why you will
get a lot of zero?
Based on my test, I add a SUM function in the table footer and it get only
one result with the correct.
The table I use is like this:
AtoC IncludeIn ID
-- -- --
NULL 1 1
NULL 0 2
1 1 3
2 0 4
0 1 5
Could you please clarify it?
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks for the reply.
The SUM is just confusing things, so ignore it. At its simplest just set up
a table and in the detail row set a cell to be 1*Fields!AtoC.Value. You'll
see that when AtoC is null you get zero displayed.
I wondered if it was a formatting issue and null was being displayed as
zero, so I modified one of the cells to be 10+(1*Fields!AtoC.Value) and got
10 when the AtoC is null.
It looks to me as though multiplying by null gives zero, rather than null.
Andrew|||Hello Andrew,
Yes. The Expression will change the Type to numeric and that force the Null
value to 0.
You need to use the IIF to specify whether it is null.
Hope this helps.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.
Monday, March 26, 2012
Proper indexs against query and optimization
Which indexes should be created on tables and how to make this query
optimized.
================================================== =====
SELECT top 1 package_description.name,
package_description.tier,
package_description.pid
FROM package_description
inner join package on package_description.pid = package.package_id
inner join courses on package.course_id = courses.id
inner join commission on package_description.pid =
commission.package_id
inner join cinfo on commission.owner_id = cinfo.cid
WHERE (courses.id = 45448) and
(cinfo.cid = 121) and
(package_description.type <> 2)
and package_description.state_id = 41
ORDER BY package_description.available ASC
================================================== =======
TIA
Kay
hi,
check your indexes and see if you are using them properly at your join
tables. may be you also need to open an execution plan and see at which step
your query is taking most precentage. also may be you should also defragment
or reubild your indexes after checking the showcontig (focus on the log and
extent results).
thx,
Tomer
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> ================================================== =====
> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid =
> commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> ================================================== =======
>
> TIA
> Kay
>
>
|||Its tough to tell you without more information about these tables, their keys
and the relationships between them (and the execution plan). Also, from the
looks of the join it appears that your model is potentially de-normalized,
this adds another potential issue.
But, from what you have listed.
A good starting point is the following (these are not always true, but a
good starting point)
1) Make sure all the tables have a primary key
2) Set the primary key as clustered
3) Create a non-clustered index on the foreign keys
So, in your case
indexes for package_description
ON pid PK clustered
ON state_id, type, available NonClustered
indexes for package
ON package_id PK Clustered
ON course_id NonClustered
index for courses
id PK Clustered
index for commission
package_ID PK clustered
owner_id nonclustered
index cinfo
cid PK Clustered
Be forewarned, this is a bit of a blind guess. But, it will hopefully get
you started in the right direction. The root of your issue could very well
be outside of just index creation, and might be related to your schema itself.
HTH
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> ================================================== =====
> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid =
> commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> ================================================== =======
>
> TIA
> Kay
>
>
sql
Proper indexs against query and optimization
Which indexes should be created on tables and how to make this query
optimized.
========================================
===============
SELECT top 1 package_description.name,
package_description.tier,
package_description.pid
FROM package_description
inner join package on package_description.pid = package.package_id
inner join courses on package.course_id = courses.id
inner join commission on package_description.pid =
commission.package_id
inner join cinfo on commission.owner_id = cinfo.cid
WHERE (courses.id = 45448) and
(cinfo.cid = 121) and
(package_description.type <> 2)
and package_description.state_id = 41
ORDER BY package_description.available ASC
========================================
=================
TIA
Kayhi,
check your indexes and see if you are using them properly at your join
tables. may be you also need to open an execution plan and see at which step
your query is taking most precentage. also may be you should also defragment
or reubild your indexes after checking the showcontig (focus on the log and
extent results).
thx,
Tomer
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> ========================================
===============
> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid =
> commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> ========================================
=================
>
> TIA
> Kay
>
>|||Its tough to tell you without more information about these tables, their key
s
and the relationships between them (and the execution plan). Also, from the
looks of the join it appears that your model is potentially de-normalized,
this adds another potential issue.
But, from what you have listed.
A good starting point is the following (these are not always true, but a
good starting point)
1) Make sure all the tables have a primary key
2) Set the primary key as clustered
3) Create a non-clustered index on the foreign keys
So, in your case
indexes for package_description
ON pid PK clustered
ON state_id, type, available NonClustered
indexes for package
ON package_id PK Clustered
ON course_id NonClustered
index for courses
id PK Clustered
index for commission
package_ID PK clustered
owner_id nonclustered
index cinfo
cid PK Clustered
Be forewarned, this is a bit of a blind guess. But, it will hopefully get
you started in the right direction. The root of your issue could very well
be outside of just index creation, and might be related to your schema itsel
f.
HTH
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> ========================================
===============
> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid =
> commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> ========================================
=================
>
> TIA
> Kay
>
>
Proper indexs against query and optimization
Which indexes should be created on tables and how to make this query
optimized.
======================================================= SELECT top 1 package_description.name,
package_description.tier,
package_description.pid
FROM package_description
inner join package on package_description.pid = package.package_id
inner join courses on package.course_id = courses.id
inner join commission on package_description.pid = commission.package_id
inner join cinfo on commission.owner_id = cinfo.cid
WHERE (courses.id = 45448) and
(cinfo.cid = 121) and
(package_description.type <> 2)
and package_description.state_id = 41
ORDER BY package_description.available ASC
=========================================================
TIA
Kayhi,
check your indexes and see if you are using them properly at your join
tables. may be you also need to open an execution plan and see at which step
your query is taking most precentage. also may be you should also defragment
or reubild your indexes after checking the showcontig (focus on the log and
extent results).
thx,
Tomer
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> =======================================================> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid => commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> =========================================================>
> TIA
> Kay
>
>|||Its tough to tell you without more information about these tables, their keys
and the relationships between them (and the execution plan). Also, from the
looks of the join it appears that your model is potentially de-normalized,
this adds another potential issue.
But, from what you have listed.
A good starting point is the following (these are not always true, but a
good starting point)
1) Make sure all the tables have a primary key
2) Set the primary key as clustered
3) Create a non-clustered index on the foreign keys
So, in your case
indexes for package_description
ON pid PK clustered
ON state_id, type, available NonClustered
indexes for package
ON package_id PK Clustered
ON course_id NonClustered
index for courses
id PK Clustered
index for commission
package_ID PK clustered
owner_id nonclustered
index cinfo
cid PK Clustered
Be forewarned, this is a bit of a blind guess. But, it will hopefully get
you started in the right direction. The root of your issue could very well
be outside of just index creation, and might be related to your schema itself.
HTH
"Kay" wrote:
> Viewing trace following query gives Duration - 517470
> Which indexes should be created on tables and how to make this query
> optimized.
> =======================================================> SELECT top 1 package_description.name,
> package_description.tier,
> package_description.pid
> FROM package_description
> inner join package on package_description.pid = package.package_id
> inner join courses on package.course_id = courses.id
> inner join commission on package_description.pid => commission.package_id
> inner join cinfo on commission.owner_id = cinfo.cid
> WHERE (courses.id = 45448) and
> (cinfo.cid = 121) and
> (package_description.type <> 2)
> and package_description.state_id = 41
> ORDER BY package_description.available ASC
> =========================================================>
> TIA
> Kay
>
>
Proper Index for a compound column?
Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
Merchandise.
Sales has InvID + AssetType as columns.
All the others have InvID + AssetType also. they would be Assettype 1,2,3,4
for the respective invnetory types
For fast joins on sales reports should I combine the 2 int columns as an
index, or are they combined and because they are int, they are added
together?
TIA
__StephenSQL Server only keeps statistics on the first column of the index.
It can (and does) use multiple indexes in the same WHERE clause.
It is recommended that you have an index for each column
that is commonly used in your WHERE clause.
--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net
Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Stephen Russell" <srussell@.lotmate.com> wrote in message
news:uQmpnJQbFHA.348@.TK2MSFTNGP14.phx.gbl...
>I have tables Sales, Trucks, Merchandise, Marine and Real Estate.
> Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
> Merchandise.
> Sales has InvID + AssetType as columns.
> All the others have InvID + AssetType also. they would be Assettype
> 1,2,3,4
> for the respective invnetory types
> For fast joins on sales reports should I combine the 2 int columns as an
> index, or are they combined and because they are int, they are added
> together?
> TIA
> __Stephen
>
>
Proper Index for a compound column?
Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
Merchandise.
Sales has InvID + AssetType as columns.
All the others have InvID + AssetType also. they would be Assettype 1,2,3,4
for the respective invnetory types
For fast joins on sales reports should I combine the 2 int columns as an
index, or are they combined and because they are int, they are added
together?
TIA
__StephenSQL Server only keeps statistics on the first column of the index.
It can (and does) use multiple indexes in the same WHERE clause.
It is recommended that you have an index for each column
that is commonly used in your WHERE clause.
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net
Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Stephen Russell" <srussell@.lotmate.com> wrote in message
news:uQmpnJQbFHA.348@.TK2MSFTNGP14.phx.gbl...
>I have tables Sales, Trucks, Merchandise, Marine and Real Estate.
> Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
> Merchandise.
> Sales has InvID + AssetType as columns.
> All the others have InvID + AssetType also. they would be Assettype
> 1,2,3,4
> for the respective invnetory types
> For fast joins on sales reports should I combine the 2 int columns as an
> index, or are they combined and because they are int, they are added
> together?
> TIA
> __Stephen
>
>
Friday, March 23, 2012
Proper Index for a compound column?
Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
Merchandise.
Sales has InvID + AssetType as columns.
All the others have InvID + AssetType also. they would be Assettype 1,2,3,4
for the respective invnetory types
For fast joins on sales reports should I combine the 2 int columns as an
index, or are they combined and because they are int, they are added
together?
TIA
__Stephen
SQL Server only keeps statistics on the first column of the index.
It can (and does) use multiple indexes in the same WHERE clause.
It is recommended that you have an index for each column
that is commonly used in your WHERE clause.
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.masterado.net
Earn $$$ money answering .NET Framework
messageboard posts at EggHeadCafe.com.
http://www.eggheadcafe.com/forums/merit.asp
"Stephen Russell" <srussell@.lotmate.com> wrote in message
news:uQmpnJQbFHA.348@.TK2MSFTNGP14.phx.gbl...
>I have tables Sales, Trucks, Merchandise, Marine and Real Estate.
> Sales is parent and is a 1:1 for Trucks, Marine, Property. It's 1:M for
> Merchandise.
> Sales has InvID + AssetType as columns.
> All the others have InvID + AssetType also. they would be Assettype
> 1,2,3,4
> for the respective invnetory types
> For fast joins on sales reports should I combine the 2 int columns as an
> index, or are they combined and because they are int, they are added
> together?
> TIA
> __Stephen
>
>
sql
Propagation of event notification when tables are updated.
when a table in my MSSql2000 server is updated.
Prog A; I have an external application adding records to a table.
Prog B; I have another external application using this table as well.
When Prog A creates a new record in the Table, how can I have Prog B be
notified of the event without polling the table or creating a link
between Prog A and Prog B.
Thanks.> When Prog A creates a new record in the Table, how can I have Prog B be
> notified of the event
Depends what you mean by "notified". If you want to invoke some code within
the current process (B) then the obvious way is to have B read a table or
watch for some other event and then act accordingly. What exactly do you
want to achieve? Is this simply about optimistic locking?
--
David Portas
SQL Server MVP
--|||dubian (collatz@.bigtexansoftware.com) writes:
> I would like to propagate an event signal to an external application
> when a table in my MSSql2000 server is updated.
> Prog A; I have an external application adding records to a table.
> Prog B; I have another external application using this table as well.
> When Prog A creates a new record in the Table, how can I have Prog B be
> notified of the event without polling the table or creating a link
> between Prog A and Prog B.
By far, the easiest way is to poll.
The other way would be to have a trigger on the table, that fires of an
extended stored procedure or OLE object to somehow send a singal to
Process B. Since extended stored procedures and local OLE objects in
the same memory space as the rest of SQL Server, they are somewhat
dangerous: if they crash on an access violation, the entire server
goes belly-up.
I believe that you also can use the sp_OAxxx routiens to start an
OLE object on a remote server. In this there is less risk for crashes.
But this is like to take time, and when you are in a trigger you are
in a transaction hold locks. If the update frequency is high, this
trigger can kill your throughput.
A variation is to have the trigger to write to a table, and then
run a job from SQL Server Agent that reads the table and alerts the
other process. Such a job would run once a minute or so. Since this job
could be an ActiveX task you could signal with XP:s and that.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
Propagate fields from elements 2 or 3 levels above current element
I am currently trying to insert multilevel data to 5 tables from one xml
source file. It inserts without errors, however, I noticed that I can only
propagate element values to the child only if the element value is from a
hierarchy above it.
For example, I have the following hierarchies/entities within a file:
<CONTROL>
<ORDER> (repeating)
<ORDER_ITEM> (repeating)
<FEATURES> (repeating)
</FEATURES>
</ORDER_ITEM>
<WORK_INSTRUCTIONS> (repeating)
</WORK_INSTRUCTIONS>
</ORDER>
</CONTROL>
In the table destined to hold fields for <FEATURES>, I also included one
field from <CONTROL> and another from <ORDER>. However, both remain blank
when I look at this table. Instead, only the the line number field from
<ORDER_ITEM> show up in addition to the fields from <FEATURES>. Is there
another way I could structure my annotated schema or tables to be able to
hold these needed fields?
I can post or send my table DDL, my annotated schema, and the sample xml
file upon request.
Regards,
Tristan
I had forgotten to bring up earlier that I am using SQLXMLBulkLoad object
from SQLXML 3 sp3 to upload the xml document to the 5 tables described.
5 tables described are as follows:
[DF_TempOrder_Control] ([XctlMsgNum],[Transaction],[Schema], [Plant],
[ParNum], [Date],[Time], [Valid])
[DF_TempOrder_Header] ([XctlMsgNum],[OrdMsgNum],[Action],[Floor_Order],
[Order_Type],[Due_Date],[Cra_Date],[AddrNumber],[Country],
[Zipcode], [Master_Order], [Ship_Tie] [nvarchar],
[RPQ], [Valid])
[DF_TempOrder_Details] ([XctlMsgNum], [Floor_Order], [MATNR],
[MATNR_DESC], [KDMAT], [KDMAT_DESC], [REVISION],
[SERIAL_YN], [REVISION_YN], [UPC_PART_YN],
[CONSIGNED_YN],[MAC_YN], [QTY],
[FLOOR_POSNR], [PARENT_POSNR], [BUNDLE_POSNR],
[VBAP_POSNR], [LIPS_POSNR], [VBAP_POSEX],
[SALES_ORDER],[SOLD_CUST_PO],[DELIVERY_NUM],
[SHIP_CUST_PO],[MACHINE_MODEL], [Valid])
[DF_TempOrder_ItemFeatures] ([XctlMsgNum],
[Floor_Order], [FLOOR_POSNR],
[Feature], [Valid])
[DF_TempOrder_Work_Instructions] ([XctlMsgNum],
[Floor_Order], [Instruction], [Valid])
My annotated schema is as follows:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="Order_Control" parent="DF_TempOrder_Control"
parent-key="XCTLMSGNUM" child="DF_TempOrder_Header"
child-key="XCTLMSGNUM" />
<sql:relationship name="Order_Detail" parent="DF_TempOrder_Header"
parent-key="FLOOR_ORDER" child="DF_TempOrder_Details"
child-key="FLOOR_ORDER" />
<sql:relationship name="OrderWI" parent="DF_TempOrder_Header"
parent-key="FLOOR_ORDER" child="DF_TempOrder_Work_Instructions"
child-key="FLOOR_ORDER" />
<sql:relationship name="OrderItemFeature" parent="DF_TempOrder_Details"
parent-key="FLOOR_POSNR" child="DF_TempOrder_Features"
child-key="FLOOR_POSNR" />
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="CONTROL" sql:relation="DF_TempOrder_Control">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="XCTLMSGNUM" type="xsd:string" />
<xsd:element name="TRANSACTION" type="xsd:string" />
<xsd:element name="SCHEMA" type="xsd:string" />
<xsd:element name="PLANT" type="xsd:string" />
<xsd:element name="PARNUM" type="xsd:string" />
<xsd:element name="DATE" type="xsd:string" />
<xsd:element name="TIME" type="xsd:string" />
<xsd:element name="ORDER" sql:relation="DF_TempOrder_Header"
sql:relationship="Order_Control">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FLOOR_ORDER" type="xsd:string" />
<xsd:element name="ORDMSGNUM" type="xsd:string" />
<xsd:element name="ACTION" type="xsd:string" />
<xsd:element name="ORDER_TYPE" type="xsd:string" />
<xsd:element name="DUE_DATE" type="xsd:string" />
<xsd:element name="CRA_DATE" type="xsd:string" />
<xsd:element name="ADDRNUMBER" type="xsd:integer" />
<xsd:element name="COUNTRY" type="xsd:string" />
<xsd:element name="ZIPCODE" type="xsd:string" />
<xsd:element name="MASTER_ORDER" type="xsd:string" />
<xsd:element name="SHIP_TIE" type="xsd:string" />
<xsd:element name="RPQ" type="xsd:string" />
<xsd:element name="ORDER_ITEM" sql:relation="DF_TempOrder_Details"
sql:relationship="Order_Detail">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MATNR" type="xsd:string" />
<xsd:element name="MATNR_DESC" type="xsd:string" />
<xsd:element name="KDMAT" type="xsd:string" />
<xsd:element name="KDMAT_DESC" type="xsd:string" />
<xsd:element name="REVISION" type="xsd:string" />
<xsd:element name="SERIAL_YN" type="xsd:string" />
<xsd:element name="REVISION_YN" type="xsd:string" />
<xsd:element name="UPC_PART_YN" type="xsd:string" />
<xsd:element name="CONSIGNED_YN" type="xsd:string" />
<xsd:element name="MAC_YN" type="xsd:string" />
<xsd:element name="QTY" type="xsd:int" />
<xsd:element name="FLOOR_POSNR" type="xsd:string" />
<xsd:element name="PARENT_POSNR" type="xsd:string" />
<xsd:element name="BUNDLE_POSNR" type="xsd:string" />
<xsd:element name="VBAP_POSNR" type="xsd:string" />
<xsd:element name="LIPS_POSNR" type="xsd:string" />
<xsd:element name="VBAP_POSEX" type="xsd:string" />
<xsd:element name="SALES_ORDER" type="xsd:string" />
<xsd:element name="SOLD_CUST_PO" type="xsd:string" />
<xsd:element name="DELIVERY_NUM" type="xsd:string" />
<xsd:element name="SHIP_CUST_PO" type="xsd:string" />
<xsd:element name="MACHINE_MODEL" type="xsd:string" />
<xsd:element name="FEATURES" sql:relation="DF_TempOrder_Features"
sql:relationship="OrderItemFeature">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FEATURE" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="WORK_INSTRUCTIONS"
sql:relation="DF_TempOrder_Work_Instructions" sql:relationship="OrderWI">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="INSTRUCTION" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
My sample xml file is as follows:
<MESSAGE>
<CONTROL>
<XCTLMSGNUM>123456789</XCTLMSGNUM>
<TRANSACTION>ORDER FOR FLOOR</TRANSACTION>
<SCHEMA>ORDER CONTENT</SCHEMA>
<PLANT>TN01</PLANT>
<PARNUM>0011</PARNUM>
<DATE>20050427</DATE>
<TIME>1237</TIME>
<ORDER>
<ORDMSGNUM>123456</ORDMSGNUM>
<ACTION>ADD</ACTION>
<FLOOR_ORDER>SAP123456</FLOOR_ORDER>
<ORDER_TYPE>ZDBO</ORDER_TYPE>
<ADDRNUMBER>123456</ADDRNUMBER>
<COUNTRY>US</COUNTRY>
<ZIPCODE>12345</ZIPCODE>
<MASTER_ORDER>DOC12345</MASTER_ORDER>
<SHIP_TIE>10823741</SHIP_TIE>
<DUE_DATE>05302005</DUE_DATE>
<CRA_DATE>06302005</CRA_DATE>
<RPQ>12345</RPQ>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION</INSTRUCTION>
</WORK_INSTRUCTIONS>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION1</INSTRUCTION>
</WORK_INSTRUCTIONS>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION2</INSTRUCTION>
</WORK_INSTRUCTIONS>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
</ORDER>
</CONTROL>
</MESSAGE>
|||Unfortunately, there is no possible mapping to perform the below action for
the given input Xml.
However, you may apply XSLT or wrap the SAX reader to inject fields which
you would like to appear in different levels. This is the one possible
workaround I can think.
"Tristan" <Tristan@.discussions.microsoft.com> wrote in message
news:ED8CDC51-FB41-4867-B77E-E92855DF11FB@.microsoft.com...
>I had forgotten to bring up earlier that I am using SQLXMLBulkLoad object
> from SQLXML 3 sp3 to upload the xml document to the 5 tables described.
> 5 tables described are as follows:
> [DF_TempOrder_Control] ([XctlMsgNum],[Transaction],[Schema], [Plant],
> [ParNum], [Date],[Time], [Valid])
> [DF_TempOrder_Header] ([XctlMsgNum],[OrdMsgNum],[Action],[Floor_Order],
> [Order_Type],[Due_Date],[Cra_Date],[AddrNumber],[Country],
> [Zipcode], [Master_Order], [Ship_Tie] [nvarchar],
> [RPQ], [Valid])
> [DF_TempOrder_Details] ([XctlMsgNum], [Floor_Order], [MATNR],
> [MATNR_DESC], [KDMAT], [KDMAT_DESC], [REVISION],
> [SERIAL_YN], [REVISION_YN], [UPC_PART_YN],
> [CONSIGNED_YN], [MAC_YN], [QTY],
> [FLOOR_POSNR], [PARENT_POSNR], [BUNDLE_POSNR],
> [VBAP_POSNR], [LIPS_POSNR], [VBAP_POSEX],
> [SALES_ORDER], [SOLD_CUST_PO], [DELIVERY_NUM],
> [SHIP_CUST_PO], [MACHINE_MODEL], [Valid])
> [DF_TempOrder_ItemFeatures] ([XctlMsgNum],
> [Floor_Order], [FLOOR_POSNR],
> [Feature], [Valid])
> [DF_TempOrder_Work_Instructions] ([XctlMsgNum],
> [Floor_Order], [Instruction], [Valid])
> My annotated schema is as follows:
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
> <xsd:annotation>
> <xsd:appinfo>
> <sql:relationship name="Order_Control" parent="DF_TempOrder_Control"
> parent-key="XCTLMSGNUM" child="DF_TempOrder_Header"
> child-key="XCTLMSGNUM" />
> <sql:relationship name="Order_Detail" parent="DF_TempOrder_Header"
> parent-key="FLOOR_ORDER" child="DF_TempOrder_Details"
> child-key="FLOOR_ORDER" />
> <sql:relationship name="OrderWI" parent="DF_TempOrder_Header"
> parent-key="FLOOR_ORDER" child="DF_TempOrder_Work_Instructions"
> child-key="FLOOR_ORDER" />
> <sql:relationship name="OrderItemFeature" parent="DF_TempOrder_Details"
> parent-key="FLOOR_POSNR" child="DF_TempOrder_Features"
> child-key="FLOOR_POSNR" />
> </xsd:appinfo>
> </xsd:annotation>
> <xsd:element name="CONTROL" sql:relation="DF_TempOrder_Control">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="XCTLMSGNUM" type="xsd:string" />
> <xsd:element name="TRANSACTION" type="xsd:string" />
> <xsd:element name="SCHEMA" type="xsd:string" />
> <xsd:element name="PLANT" type="xsd:string" />
> <xsd:element name="PARNUM" type="xsd:string" />
> <xsd:element name="DATE" type="xsd:string" />
> <xsd:element name="TIME" type="xsd:string" />
> <xsd:element name="ORDER" sql:relation="DF_TempOrder_Header"
> sql:relationship="Order_Control">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="FLOOR_ORDER" type="xsd:string" />
> <xsd:element name="ORDMSGNUM" type="xsd:string" />
> <xsd:element name="ACTION" type="xsd:string" />
> <xsd:element name="ORDER_TYPE" type="xsd:string" />
> <xsd:element name="DUE_DATE" type="xsd:string" />
> <xsd:element name="CRA_DATE" type="xsd:string" />
> <xsd:element name="ADDRNUMBER" type="xsd:integer" />
> <xsd:element name="COUNTRY" type="xsd:string" />
> <xsd:element name="ZIPCODE" type="xsd:string" />
> <xsd:element name="MASTER_ORDER" type="xsd:string" />
> <xsd:element name="SHIP_TIE" type="xsd:string" />
> <xsd:element name="RPQ" type="xsd:string" />
> <xsd:element name="ORDER_ITEM" sql:relation="DF_TempOrder_Details"
> sql:relationship="Order_Detail">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="MATNR" type="xsd:string" />
> <xsd:element name="MATNR_DESC" type="xsd:string" />
> <xsd:element name="KDMAT" type="xsd:string" />
> <xsd:element name="KDMAT_DESC" type="xsd:string" />
> <xsd:element name="REVISION" type="xsd:string" />
> <xsd:element name="SERIAL_YN" type="xsd:string" />
> <xsd:element name="REVISION_YN" type="xsd:string" />
> <xsd:element name="UPC_PART_YN" type="xsd:string" />
> <xsd:element name="CONSIGNED_YN" type="xsd:string" />
> <xsd:element name="MAC_YN" type="xsd:string" />
> <xsd:element name="QTY" type="xsd:int" />
> <xsd:element name="FLOOR_POSNR" type="xsd:string" />
> <xsd:element name="PARENT_POSNR" type="xsd:string" />
> <xsd:element name="BUNDLE_POSNR" type="xsd:string" />
> <xsd:element name="VBAP_POSNR" type="xsd:string" />
> <xsd:element name="LIPS_POSNR" type="xsd:string" />
> <xsd:element name="VBAP_POSEX" type="xsd:string" />
> <xsd:element name="SALES_ORDER" type="xsd:string" />
> <xsd:element name="SOLD_CUST_PO" type="xsd:string" />
> <xsd:element name="DELIVERY_NUM" type="xsd:string" />
> <xsd:element name="SHIP_CUST_PO" type="xsd:string" />
> <xsd:element name="MACHINE_MODEL" type="xsd:string" />
> <xsd:element name="FEATURES" sql:relation="DF_TempOrder_Features"
> sql:relationship="OrderItemFeature">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="FEATURE" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> <xsd:element name="WORK_INSTRUCTIONS"
> sql:relation="DF_TempOrder_Work_Instructions" sql:relationship="OrderWI">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="INSTRUCTION" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> My sample xml file is as follows:
> <MESSAGE>
> <CONTROL>
> <XCTLMSGNUM>123456789</XCTLMSGNUM>
> <TRANSACTION>ORDER FOR FLOOR</TRANSACTION>
> <SCHEMA>ORDER CONTENT</SCHEMA>
> <PLANT>TN01</PLANT>
> <PARNUM>0011</PARNUM>
> <DATE>20050427</DATE>
> <TIME>1237</TIME>
> <ORDER>
> <ORDMSGNUM>123456</ORDMSGNUM>
> <ACTION>ADD</ACTION>
> <FLOOR_ORDER>SAP123456</FLOOR_ORDER>
> <ORDER_TYPE>ZDBO</ORDER_TYPE>
> <ADDRNUMBER>123456</ADDRNUMBER>
> <COUNTRY>US</COUNTRY>
> <ZIPCODE>12345</ZIPCODE>
> <MASTER_ORDER>DOC12345</MASTER_ORDER>
> <SHIP_TIE>10823741</SHIP_TIE>
> <DUE_DATE>05302005</DUE_DATE>
> <CRA_DATE>06302005</CRA_DATE>
> <RPQ>12345</RPQ>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION1</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION2</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> </ORDER>
> </CONTROL>
> </MESSAGE>
|||Other solutions include:
Write your own shredder on the midtier.
Pass the data to the database and use OpenXML in SS2000 (or nodes() in
SS2005) to get at the parent.
Best regards
Michael
"Bertan ARI [MSFT]" <bertan@.online.microsoft.com> wrote in message
news:uUX%23VvRbFHA.2520@.TK2MSFTNGP09.phx.gbl...
> Unfortunately, there is no possible mapping to perform the below action
> for the given input Xml.
> However, you may apply XSLT or wrap the SAX reader to inject fields which
> you would like to appear in different levels. This is the one possible
> workaround I can think.
>
> "Tristan" <Tristan@.discussions.microsoft.com> wrote in message
> news:ED8CDC51-FB41-4867-B77E-E92855DF11FB@.microsoft.com...
>
Propagate fields from elements 2 or 3 levels above current element
I am currently trying to insert multilevel data to 5 tables from one xml
source file. It inserts without errors, however, I noticed that I can only
propagate element values to the child only if the element value is from a
hierarchy above it.
For example, I have the following hierarchies/entities within a file:
<CONTROL>
<ORDER> (repeating)
<ORDER_ITEM> (repeating)
<FEATURES> (repeating)
</FEATURES>
</ORDER_ITEM>
<WORK_INSTRUCTIONS> (repeating)
</WORK_INSTRUCTIONS>
</ORDER>
</CONTROL>
In the table destined to hold fields for <FEATURES>, I also included one
field from <CONTROL> and another from <ORDER>. However, both remain blank
when I look at this table. Instead, only the the line number field from
<ORDER_ITEM> show up in addition to the fields from <FEATURES>. Is there
another way I could structure my annotated schema or tables to be able to
hold these needed fields?
I can post or send my table DDL, my annotated schema, and the sample xml
file upon request.
Regards,
TristanI had forgotten to bring up earlier that I am using SQLXMLBulkLoad object
from SQLXML 3 sp3 to upload the xml document to the 5 tables described.
5 tables described are as follows:
[DF_TempOrder_Control] ([XctlMsgNum],[Transaction],[Schema], [Plant],
[ParNum], [Date],[Time], [Valid])
[DF_TempOrder_Header] ([XctlMsgNum],[OrdMsgNum],[Action],[Floo
r_Order],
[Order_Type],[Due_Date],[Cra_Date],[Addr
Number],[Country],
[Zipcode], [Master_Order], [Ship_Tie] [nvarchar],
[RPQ], [Valid])
[DF_TempOrder_Details] ([XctlMsgNum], [Floor_Order], [MATNR],
[MATNR_DESC], [KDMAT], [KDMAT_DESC], [REVISION],
[SERIAL_YN], [REVISION_YN], [UPC_PART_YN],
[CONSIGNED_YN], [MAC_YN], [QTY],
[FLOOR_POSNR], [PARENT_POSNR], [BUNDLE_POSNR],
[VBAP_POSNR], [LIPS_POSNR], [VBAP_POSEX],
[SALES_ORDER], [SOLD_CUST_PO], [DELIVERY
_NUM],
[SHIP_CUST_PO], [MACHINE_MODEL], [Valid])
[DF_TempOrder_ItemFeatures] ([XctlMsgNum],
[Floor_Order], [FLOOR_POSNR],
[Feature], [Valid])
[DF_TempOrder_Work_Instructions] ([XctlMsgNum],
[Floor_Order], [Instruction], [Valid])
My annotated schema is as follows:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="Order_Control" parent="DF_TempOrder_Control"
parent-key="XCTLMSGNUM" child="DF_TempOrder_Header"
child-key="XCTLMSGNUM" />
<sql:relationship name="Order_Detail" parent="DF_TempOrder_Header"
parent-key="FLOOR_ORDER" child="DF_TempOrder_Details"
child-key="FLOOR_ORDER" />
<sql:relationship name="OrderWI" parent="DF_TempOrder_Header"
parent-key="FLOOR_ORDER" child="DF_TempOrder_Work_Instructions"
child-key="FLOOR_ORDER" />
<sql:relationship name="OrderItemFeature" parent="DF_TempOrder_Details"
parent-key="FLOOR_POSNR" child="DF_TempOrder_Features"
child-key="FLOOR_POSNR" />
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="CONTROL" sql:relation="DF_TempOrder_Control">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="XCTLMSGNUM" type="xsd:string" />
<xsd:element name="TRANSACTION" type="xsd:string" />
<xsd:element name="SCHEMA" type="xsd:string" />
<xsd:element name="PLANT" type="xsd:string" />
<xsd:element name="PARNUM" type="xsd:string" />
<xsd:element name="DATE" type="xsd:string" />
<xsd:element name="TIME" type="xsd:string" />
<xsd:element name="ORDER" sql:relation="DF_TempOrder_Header"
sql:relationship="Order_Control">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FLOOR_ORDER" type="xsd:string" />
<xsd:element name="ORDMSGNUM" type="xsd:string" />
<xsd:element name="ACTION" type="xsd:string" />
<xsd:element name="ORDER_TYPE" type="xsd:string" />
<xsd:element name="DUE_DATE" type="xsd:string" />
<xsd:element name="CRA_DATE" type="xsd:string" />
<xsd:element name="ADDRNUMBER" type="xsd:integer" />
<xsd:element name="COUNTRY" type="xsd:string" />
<xsd:element name="ZIPCODE" type="xsd:string" />
<xsd:element name="MASTER_ORDER" type="xsd:string" />
<xsd:element name="SHIP_TIE" type="xsd:string" />
<xsd:element name="RPQ" type="xsd:string" />
<xsd:element name="ORDER_ITEM" sql:relation="DF_TempOrder_Details"
sql:relationship="Order_Detail">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MATNR" type="xsd:string" />
<xsd:element name="MATNR_DESC" type="xsd:string" />
<xsd:element name="KDMAT" type="xsd:string" />
<xsd:element name="KDMAT_DESC" type="xsd:string" />
<xsd:element name="REVISION" type="xsd:string" />
<xsd:element name="SERIAL_YN" type="xsd:string" />
<xsd:element name="REVISION_YN" type="xsd:string" />
<xsd:element name="UPC_PART_YN" type="xsd:string" />
<xsd:element name="CONSIGNED_YN" type="xsd:string" />
<xsd:element name="MAC_YN" type="xsd:string" />
<xsd:element name="QTY" type="xsd:int" />
<xsd:element name="FLOOR_POSNR" type="xsd:string" />
<xsd:element name="PARENT_POSNR" type="xsd:string" />
<xsd:element name="BUNDLE_POSNR" type="xsd:string" />
<xsd:element name="VBAP_POSNR" type="xsd:string" />
<xsd:element name="LIPS_POSNR" type="xsd:string" />
<xsd:element name="VBAP_POSEX" type="xsd:string" />
<xsd:element name="SALES_ORDER" type="xsd:string" />
<xsd:element name="SOLD_CUST_PO" type="xsd:string" />
<xsd:element name="DELIVERY_NUM" type="xsd:string" />
<xsd:element name="SHIP_CUST_PO" type="xsd:string" />
<xsd:element name="MACHINE_MODEL" type="xsd:string" />
<xsd:element name="FEATURES" sql:relation="DF_TempOrder_Features"
sql:relationship="OrderItemFeature">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="FEATURE" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="WORK_INSTRUCTIONS"
sql:relation="DF_TempOrder_Work_Instructions" sql:relationship="OrderWI">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="INSTRUCTION" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
My sample xml file is as follows:
<MESSAGE>
<CONTROL>
<XCTLMSGNUM>123456789</XCTLMSGNUM>
<TRANSACTION>ORDER FOR FLOOR</TRANSACTION>
<SCHEMA>ORDER CONTENT</SCHEMA>
<PLANT>TN01</PLANT>
<PARNUM>0011</PARNUM>
<DATE>20050427</DATE>
<TIME>1237</TIME>
<ORDER>
<ORDMSGNUM>123456</ORDMSGNUM>
<ACTION>ADD</ACTION>
<FLOOR_ORDER>SAP123456</FLOOR_ORDER>
<ORDER_TYPE>ZDBO</ORDER_TYPE>
<ADDRNUMBER>123456</ADDRNUMBER>
<COUNTRY>US</COUNTRY>
<ZIPCODE>12345</ZIPCODE>
<MASTER_ORDER>DOC12345</MASTER_ORDER>
<SHIP_TIE>10823741</SHIP_TIE>
<DUE_DATE>05302005</DUE_DATE>
<CRA_DATE>06302005</CRA_DATE>
<RPQ>12345</RPQ>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION</INSTRUCTION>
</WORK_INSTRUCTIONS>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION1</INSTRUCTION>
</WORK_INSTRUCTIONS>
<WORK_INSTRUCTIONS>
<INSTRUCTION>THIS IS TEST INSTRUCTION2</INSTRUCTION>
</WORK_INSTRUCTIONS>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
<ORDER_ITEM>
<MATNR>PART A</MATNR>
<MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
<KDMAT>CUST PART A</KDMAT>
<KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
<REVISION>N</REVISION>
<SERIAL_YN>Y</SERIAL_YN>
<REVISION_YN>N</REVISION_YN>
<UPC_PART_YN>N</UPC_PART_YN>
<CONSIGNED_YN>Y</CONSIGNED_YN>
<MAC_YN>Y</MAC_YN>
<QTY>1</QTY>
<FLOOR_POSNR>12345</FLOOR_POSNR>
<PARENT_POSNR>0000</PARENT_POSNR>
<BUNDLE_POSNR>0000</BUNDLE_POSNR>
<VBAP_POSNR>1000</VBAP_POSNR>
<LIPS_POSNR>0001</LIPS_POSNR>
<VBAP_POSEX>0001</VBAP_POSEX>
<FEATURES>
<FEATURE>PRINT ON BOX</FEATURE>
</FEATURES>
<FEATURES>
<FEATURE>PRINT ON BOX 2</FEATURE>
</FEATURES>
<SALES_ORDER>Used at line level when</SALES_ORDER>
<SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
<DELIVERY_NUM>DOC12345</DELIVERY_NUM>
<SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
<MACHINE_MODEL>6400-800</MACHINE_MODEL>
</ORDER_ITEM>
</ORDER>
</CONTROL>
</MESSAGE>|||Unfortunately, there is no possible mapping to perform the below action for
the given input Xml.
However, you may apply XSLT or wrap the SAX reader to inject fields which
you would like to appear in different levels. This is the one possible
workaround I can think.
"Tristan" <Tristan@.discussions.microsoft.com> wrote in message
news:ED8CDC51-FB41-4867-B77E-E92855DF11FB@.microsoft.com...
>I had forgotten to bring up earlier that I am using SQLXMLBulkLoad object
> from SQLXML 3 sp3 to upload the xml document to the 5 tables described.
> 5 tables described are as follows:
> [DF_TempOrder_Control] ([XctlMsgNum],[Transaction],[Schema], [Plant],
> [ParNum], [Date],[Time], [Valid])
> [DF_TempOrder_Header] ([XctlMsgNum],[OrdMsgNum],[Action],[Floo
r_Order],
> [Order_Type],[Due_Date],[Cra_Date],[Addr
Number],[Country],
> [Zipcode], [Master_Order], [Ship_Tie] [nvarchar],
> [RPQ], [Valid])
> [DF_TempOrder_Details] ([XctlMsgNum], [Floor_Order], [MATNR],
> [MATNR_DESC], [KDMAT], [KDMAT_DESC], [REVISION],
> [SERIAL_YN], [REVISION_YN], [UPC_PART_YN],
> [CONSIGNED_YN], [MAC_YN], [QTY],
> [FLOOR_POSNR], [PARENT_POSNR], [BUNDLE_POSNR],
> [VBAP_POSNR], [LIPS_POSNR], [VBAP_POSEX],
> [SALES_ORDER], [SOLD_CUST_PO], [DELIVERY_NUM],
> [SHIP_CUST_PO], [MACHINE_MODEL], [Valid])
> [DF_TempOrder_ItemFeatures] ([XctlMsgNum],
> [Floor_Order], [FLOOR_POSNR],
> [Feature], [Valid])
> [DF_TempOrder_Work_Instructions] ([XctlMsgNum],
> [Floor_Order], [Instruction], [Valid])
> My annotated schema is as follows:
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
> <xsd:annotation>
> <xsd:appinfo>
> <sql:relationship name="Order_Control" parent="DF_TempOrder_Control"
> parent-key="XCTLMSGNUM" child="DF_TempOrder_Header"
> child-key="XCTLMSGNUM" />
> <sql:relationship name="Order_Detail" parent="DF_TempOrder_Header"
> parent-key="FLOOR_ORDER" child="DF_TempOrder_Details"
> child-key="FLOOR_ORDER" />
> <sql:relationship name="OrderWI" parent="DF_TempOrder_Header"
> parent-key="FLOOR_ORDER" child="DF_TempOrder_Work_Instructions"
> child-key="FLOOR_ORDER" />
> <sql:relationship name="OrderItemFeature" parent="DF_TempOrder_Details"
> parent-key="FLOOR_POSNR" child="DF_TempOrder_Features"
> child-key="FLOOR_POSNR" />
> </xsd:appinfo>
> </xsd:annotation>
> <xsd:element name="CONTROL" sql:relation="DF_TempOrder_Control">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="XCTLMSGNUM" type="xsd:string" />
> <xsd:element name="TRANSACTION" type="xsd:string" />
> <xsd:element name="SCHEMA" type="xsd:string" />
> <xsd:element name="PLANT" type="xsd:string" />
> <xsd:element name="PARNUM" type="xsd:string" />
> <xsd:element name="DATE" type="xsd:string" />
> <xsd:element name="TIME" type="xsd:string" />
> <xsd:element name="ORDER" sql:relation="DF_TempOrder_Header"
> sql:relationship="Order_Control">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="FLOOR_ORDER" type="xsd:string" />
> <xsd:element name="ORDMSGNUM" type="xsd:string" />
> <xsd:element name="ACTION" type="xsd:string" />
> <xsd:element name="ORDER_TYPE" type="xsd:string" />
> <xsd:element name="DUE_DATE" type="xsd:string" />
> <xsd:element name="CRA_DATE" type="xsd:string" />
> <xsd:element name="ADDRNUMBER" type="xsd:integer" />
> <xsd:element name="COUNTRY" type="xsd:string" />
> <xsd:element name="ZIPCODE" type="xsd:string" />
> <xsd:element name="MASTER_ORDER" type="xsd:string" />
> <xsd:element name="SHIP_TIE" type="xsd:string" />
> <xsd:element name="RPQ" type="xsd:string" />
> <xsd:element name="ORDER_ITEM" sql:relation="DF_TempOrder_Details"
> sql:relationship="Order_Detail">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="MATNR" type="xsd:string" />
> <xsd:element name="MATNR_DESC" type="xsd:string" />
> <xsd:element name="KDMAT" type="xsd:string" />
> <xsd:element name="KDMAT_DESC" type="xsd:string" />
> <xsd:element name="REVISION" type="xsd:string" />
> <xsd:element name="SERIAL_YN" type="xsd:string" />
> <xsd:element name="REVISION_YN" type="xsd:string" />
> <xsd:element name="UPC_PART_YN" type="xsd:string" />
> <xsd:element name="CONSIGNED_YN" type="xsd:string" />
> <xsd:element name="MAC_YN" type="xsd:string" />
> <xsd:element name="QTY" type="xsd:int" />
> <xsd:element name="FLOOR_POSNR" type="xsd:string" />
> <xsd:element name="PARENT_POSNR" type="xsd:string" />
> <xsd:element name="BUNDLE_POSNR" type="xsd:string" />
> <xsd:element name="VBAP_POSNR" type="xsd:string" />
> <xsd:element name="LIPS_POSNR" type="xsd:string" />
> <xsd:element name="VBAP_POSEX" type="xsd:string" />
> <xsd:element name="SALES_ORDER" type="xsd:string" />
> <xsd:element name="SOLD_CUST_PO" type="xsd:string" />
> <xsd:element name="DELIVERY_NUM" type="xsd:string" />
> <xsd:element name="SHIP_CUST_PO" type="xsd:string" />
> <xsd:element name="MACHINE_MODEL" type="xsd:string" />
> <xsd:element name="FEATURES" sql:relation="DF_TempOrder_Features"
> sql:relationship="OrderItemFeature">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="FEATURE" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> <xsd:element name="WORK_INSTRUCTIONS"
> sql:relation="DF_TempOrder_Work_Instructions" sql:relationship="OrderWI">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="INSTRUCTION" type="xsd:string" />
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
> My sample xml file is as follows:
> <MESSAGE>
> <CONTROL>
> <XCTLMSGNUM>123456789</XCTLMSGNUM>
> <TRANSACTION>ORDER FOR FLOOR</TRANSACTION>
> <SCHEMA>ORDER CONTENT</SCHEMA>
> <PLANT>TN01</PLANT>
> <PARNUM>0011</PARNUM>
> <DATE>20050427</DATE>
> <TIME>1237</TIME>
> <ORDER>
> <ORDMSGNUM>123456</ORDMSGNUM>
> <ACTION>ADD</ACTION>
> <FLOOR_ORDER>SAP123456</FLOOR_ORDER>
> <ORDER_TYPE>ZDBO</ORDER_TYPE>
> <ADDRNUMBER>123456</ADDRNUMBER>
> <COUNTRY>US</COUNTRY>
> <ZIPCODE>12345</ZIPCODE>
> <MASTER_ORDER>DOC12345</MASTER_ORDER>
> <SHIP_TIE>10823741</SHIP_TIE>
> <DUE_DATE>05302005</DUE_DATE>
> <CRA_DATE>06302005</CRA_DATE>
> <RPQ>12345</RPQ>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION1</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <WORK_INSTRUCTIONS>
> <INSTRUCTION>THIS IS TEST INSTRUCTION2</INSTRUCTION>
> </WORK_INSTRUCTIONS>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> <ORDER_ITEM>
> <MATNR>PART A</MATNR>
> <MATNR_DESC>PART DESCRIPTION</MATNR_DESC>
> <KDMAT>CUST PART A</KDMAT>
> <KDMAT_DESC>CUST PART DESCRIPTION</KDMAT_DESC>
> <REVISION>N</REVISION>
> <SERIAL_YN>Y</SERIAL_YN>
> <REVISION_YN>N</REVISION_YN>
> <UPC_PART_YN>N</UPC_PART_YN>
> <CONSIGNED_YN>Y</CONSIGNED_YN>
> <MAC_YN>Y</MAC_YN>
> <QTY>1</QTY>
> <FLOOR_POSNR>12345</FLOOR_POSNR>
> <PARENT_POSNR>0000</PARENT_POSNR>
> <BUNDLE_POSNR>0000</BUNDLE_POSNR>
> <VBAP_POSNR>1000</VBAP_POSNR>
> <LIPS_POSNR>0001</LIPS_POSNR>
> <VBAP_POSEX>0001</VBAP_POSEX>
> <FEATURES>
> <FEATURE>PRINT ON BOX</FEATURE>
> </FEATURES>
> <FEATURES>
> <FEATURE>PRINT ON BOX 2</FEATURE>
> </FEATURES>
> <SALES_ORDER>Used at line level when</SALES_ORDER>
> <SOLD_CUST_PO>PO12345</SOLD_CUST_PO>
> <DELIVERY_NUM>DOC12345</DELIVERY_NUM>
> <SHIP_CUST_PO>PO12345</SHIP_CUST_PO>
> <MACHINE_MODEL>6400-800</MACHINE_MODEL>
> </ORDER_ITEM>
> </ORDER>
> </CONTROL>
> </MESSAGE>sql
prompt user from stored procedure?
The procedure currently skips over recipient tables that are already populated with the data that's being moved. I want the ability to either skip the table or delete the existing records from the recpient table data based on the user's response. Therefore, I somehow need to prompt the user to get a response when the data already exists in the existing table.
Is there any way to prompt the user from a stored procedure, or do I have to re-develop the procedure in DTS or write and application?You need to write an application. SQL Server has no built in interface for interacting with the user.
Your simplest approach might be to create an Access Data Project tied to your SQL Server database. Then you could easily create forms and vb code to do what you want.|||That's what I initially thought. Thanks.
Tuesday, March 20, 2012
Project Planning
Based on three tables (Projects, Tasks and UserCalender) I would like
to work out the total amount of available resources (UserCalender
table contains a entry for each user for each day, day being 7.5
hours) and total required effort (sum of Tasks.EstimateLikley) split
over 12 months.
For example:
Jan:
Available Resources: (4 Users, 7.5 hours per day, 5 working days per
week, 23 Working days in Jan) = (23 x 4) = (92 * 7.5) = 690 Available
Hours
Required Resources:
Project Start Date: 1/1/2007
Project End Date: 1/6/2007
Total Required effort (Sum of Tasks.Hours for above project): 500
Hours Average over 6 months = 83.33 Hours per month, so in Jan I need
to deduct 83.33 from 600 = 516.67 Hours.
etc
How could I do this, I have tried several ways but finding it hard.
ThanksPP (paul@.bobbob.net) writes:
Quote:
Originally Posted by
Based on three tables (Projects, Tasks and UserCalender) I would like
to work out the total amount of available resources (UserCalender
table contains a entry for each user for each day, day being 7.5
hours) and total required effort (sum of Tasks.EstimateLikley) split
over 12 months.
>
For example:
>
>
Jan:
Available Resources: (4 Users, 7.5 hours per day, 5 working days per
week, 23 Working days in Jan) = (23 x 4) = (92 * 7.5) = 690 Available
Hours
Required Resources:
Project Start Date: 1/1/2007
Project End Date: 1/6/2007
Total Required effort (Sum of Tasks.Hours for above project): 500
Hours Average over 6 months = 83.33 Hours per month, so in Jan I need
to deduct 83.33 from 600 = 516.67 Hours.
>
etc
>
How could I do this, I have tried several ways but finding it hard.
Is this disguise for your real business problem? I mean, project-
planning tools are plentiful on the market, so I don't see why you
would write your own. Or is it a class assignment?
In any case, for this types of questions, it helps if you post:
o CREATE TABLE statements for your tables.
o INSERT statements with sample data.
o The desired result given the sample.
This helps to clarify ambiguities in your post, and it also makes it
easy to copy and past to develop a tested solution.
... although, if it's really a class assignment, you are better to
discuss the problem with your teacher. You are likely to learn more
that way.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx
Friday, March 9, 2012
Programmatically deleting Indexes
Is this possible? I was thinking about using SQL DMO to do this.
adv-thanks-anceYou can iterate through the Indexes collection of a table and then use the
Remove method to drop the index.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
"Deleting indexes through code" <Deleting indexes through
code@.discussions.microsoft.com> wrote in message
news:F01486EA-4B47-4995-A3F5-498F92D2342E@.microsoft.com...
> How do you programmatically delete ALL indexes for all tables in SQL
> Server?
> Is this possible? I was thinking about using SQL DMO to do this.
> adv-thanks-ance|||ALL of the indexes for the ENTIRE SQL Server (including all databases) ?
Might want to test that out prior to implementing it on a production
machine.
Check out the Remove method of the Indexes collection in SQL-DMO.
T-SQL - could try something like this for one db (not fully tested):
SELECT 'DROP INDEX [' + OBJECT_NAME(ID) + '.' + NAME + ']'
FROM SYSINDEXES
WHERE NAME NOT LIKE 'SYS%' AND NAME NOT LIKE 'DT%' AND NAME NOT LIKE '_WA%'
AND OBJECT_NAME(ID) NOT LIKE 'SYS%'
AND OBJECT_NAME(ID) NOT LIKE 'MS%' AND OBJECT_NAME(ID) NOT LIKE 'DT%'
AND INDID >= 1 AND INDID < 255
ORDER BY OBJECT_NAME(ID), NAME
Then copy/paste/run the resultset in a query window in QA. Since an index
associated with a constraint cannot be dropped outside of dropping the
constraint, you might have to remove some of the entries listed and drop the
constraint manually. But this might help get you started.
HTH
Jerry
"Deleting indexes through code" <Deleting indexes through
code@.discussions.microsoft.com> wrote in message
news:F01486EA-4B47-4995-A3F5-498F92D2342E@.microsoft.com...
> How do you programmatically delete ALL indexes for all tables in SQL
> Server?
> Is this possible? I was thinking about using SQL DMO to do this.
> adv-thanks-ance|||The thing about dropping and re-creating indexes is that it involves
interrupting access to the database tables. Perhaps what you are wanting to
do is periodically defragment indexes. DBCC INDEXDEFRAG does not interrupt
queries and is typically faster than REINDEX.
Microsoft SQL Server 2000 Index Defragmentation Best Practices
http://www.microsoft.com/technet/pr...n/ss2kidbp.mspx
"Deleting indexes through code" <Deleting indexes through
code@.discussions.microsoft.com> wrote in message
news:F01486EA-4B47-4995-A3F5-498F92D2342E@.microsoft.com...
> How do you programmatically delete ALL indexes for all tables in SQL
> Server?
> Is this possible? I was thinking about using SQL DMO to do this.
> adv-thanks-ance|||Take a look at this example:
http://milambda.blogspot.com/2005/0...in-current.html
...and tailor it to suit your needs.
ML|||If you use this be sure you increase or have ample room in the transaction
log for that database.
"ML" <ML@.discussions.microsoft.com> wrote in message
news:4F244CDB-0144-4EB9-ADAD-7F36D423CB42@.microsoft.com...
> Take a look at this example:
> [url]http://milambda.blogspot.com/2005/07/defragment-all-indexes-in-current.html[/url
]
> ...and tailor it to suit your needs.
>
> ML|||Unlike REINDEX, which rebuilds the entire index in one large transaction,
INDEXDEFRAG only re-aranges the physical position of specific index pages as
needed, and each unit of work is in a seperate transaction, so it would
typically use less transaction logging.
[url]http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx#EFAA[
/url]
"Jerry Spivey" <jspivey@.vestas-awt.com> wrote in message
news:%23YMV3N6wFHA.2540@.TK2MSFTNGP09.phx.gbl...
> If you use this be sure you increase or have ample room in the transaction
> log for that database.
> "ML" <ML@.discussions.microsoft.com> wrote in message
> news:4F244CDB-0144-4EB9-ADAD-7F36D423CB42@.microsoft.com...
>
Saturday, February 25, 2012
Programatticaly finding constraint "check existing data on creatio
creation" , "Enforce relationship for replication" , "Enforce relationship
for INSERTs and UPDATEs"
How to determine these programmaticaly from sysconstraints, sysrelationship
or from any other table?.
It appears that this information is hiding in the "status" field in
sysconstraints.
Any help ?
Check properties (CnstIsNotTrusted, CnstIsNotRepl, CnstIsDisabled) using
function objectproperty, they are the contrary.
select
object_name([id]),
object_name(constid),
~ cast(objectproperty(constid, 'CnstIsNotTrusted') as bit) as 'Check
existing data on creation',
~ cast(objectproperty(constid, 'CnstIsNotRepl') as bit) as 'Enforce
relationship for replication',
~ cast(objectproperty(constid, 'CnstIsDisabled') as bit) as 'Enforce
relationship for INSERTs and UPDATEs'
from
sysconstraints
where
object_name([id]) = 'order details'
and object_name(constid) = 'FK_Order_Details_Orders'
AMB
"swami" wrote:
> A relationship between 2 tables has a property "check existing data on
> creation" , "Enforce relationship for replication" , "Enforce relationship
> for INSERTs and UPDATEs"
> How to determine these programmaticaly from sysconstraints, sysrelationship
> or from any other table?.
> It appears that this information is hiding in the "status" field in
> sysconstraints.
> Any help ?
Programatticaly finding constraint "check existing data on creatio
creation" , "Enforce relationship for replication" , "Enforce relationship
for INSERTs and UPDATEs"
How to determine these programmaticaly from sysconstraints, sysrelationship
or from any other table?.
It appears that this information is hiding in the "status" field in
sysconstraints.
Any help ?Check properties (CnstIsNotTrusted, CnstIsNotRepl, CnstIsDisabled) using
function objectproperty, they are the contrary.
select
object_name([id]),
object_name(constid),
~ cast(objectproperty(constid, 'CnstIsNotTrusted') as bit) as 'Check
existing data on creation',
~ cast(objectproperty(constid, 'CnstIsNotRepl') as bit) as 'Enforce
relationship for replication',
~ cast(objectproperty(constid, 'CnstIsDisabled') as bit) as 'Enforce
relationship for INSERTs and UPDATEs'
from
sysconstraints
where
object_name([id]) = 'order details'
and object_name(constid) = 'FK_Order_Details_Orders'
AMB
"swami" wrote:
> A relationship between 2 tables has a property "check existing data on
> creation" , "Enforce relationship for replication" , "Enforce relationship
> for INSERTs and UPDATEs"
> How to determine these programmaticaly from sysconstraints, sysrelationshi
p
> or from any other table?.
> It appears that this information is hiding in the "status" field in
> sysconstraints.
> Any help ?
Programatticaly finding constraint "check existing data on creatio
creation" , "Enforce relationship for replication" , "Enforce relationship
for INSERTs and UPDATEs"
How to determine these programmaticaly from sysconstraints, sysrelationship
or from any other table?.
It appears that this information is hiding in the "status" field in
sysconstraints.
Any help ?Check properties (CnstIsNotTrusted, CnstIsNotRepl, CnstIsDisabled) using
function objectproperty, they are the contrary.
select
object_name([id]),
object_name(constid),
~ cast(objectproperty(constid, 'CnstIsNotTrusted') as bit) as 'Check
existing data on creation',
~ cast(objectproperty(constid, 'CnstIsNotRepl') as bit) as 'Enforce
relationship for replication',
~ cast(objectproperty(constid, 'CnstIsDisabled') as bit) as 'Enforce
relationship for INSERTs and UPDATEs'
from
sysconstraints
where
object_name([id]) = 'order details'
and object_name(constid) = 'FK_Order_Details_Orders'
AMB
"swami" wrote:
> A relationship between 2 tables has a property "check existing data on
> creation" , "Enforce relationship for replication" , "Enforce relationship
> for INSERTs and UPDATEs"
> How to determine these programmaticaly from sysconstraints, sysrelationship
> or from any other table?.
> It appears that this information is hiding in the "status" field in
> sysconstraints.
> Any help ?