Showing posts with label xml. Show all posts
Showing posts with label xml. Show all posts

Monday, March 19, 2012

Need security advice on xp_cmdshell, bcp, xml procedure

I have a stored procedure that creates an xml file. It executes a SELECT
statement with the FOR XML clause and then writes the xml file using bcp and
xp_cmdshell. I am calling this procedure by passing it a parameter via ADO.
I have configured the SQL Server Agent with a proxy account so non-SysAdmin
can execute xp_cmdshell.

I'm concerned about giving non-SysAdmins execute on xp_cmdshell. I'm also
concerned about having to maintain the password on my proxy account when
that users' password changes.

Is there a better, more secure way to generate this xml file.

ThanksTerri (terri@.cybernets.com) writes:
> I have a stored procedure that creates an xml file. It executes a SELECT
> statement with the FOR XML clause and then writes the xml file using bcp
> and xp_cmdshell. I am calling this procedure by passing it a parameter
> via ADO. I have configured the SQL Server Agent with a proxy account so
> non-SysAdmin can execute xp_cmdshell.
> I'm concerned about giving non-SysAdmins execute on xp_cmdshell. I'm also
> concerned about having to maintain the password on my proxy account when
> that users' password changes.
> Is there a better, more secure way to generate this xml file.

I'm not really sure what you but it sounds like you do something like:

bcp "SELECT ... FOR XML" queryout outfile.bcp

This is not likely to work very well. ODBC will chop the XML document
after each 2033 character. See KB 275583.

So you would need to get the XML document to the client, and have the
client to create the file and put it where it belongs. Which probably
is better from a security perspective as well.

--
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|||> This is not likely to work very well. ODBC will chop the XML document
> after each 2033 character. See KB 275583.
> So you would need to get the XML document to the client, and have the
> client to create the file and put it where it belongs. Which probably
> is better from a security perspective as well.

Thanks Erland,

I'm not using Query Analyzer so I don't think KB 275583 applies to me.

I'm calling the following procedure via ADO

CREATE PROCEDURE procGenerateXML
@.CheckRequestID int
AS
declare @.sql nvarchar(4000)
set @.sql= 'bcp "EXEC TestDB..proctest ' + CONVERT(varchar(8),@.ID) + '"' + '
queryout test.xml -SServer1 -T -c -r -t'
exec master..xp_cmdshell @.sql
GO

The procedure proctest looks like:

CREATE PROCEDURE proctest
@.ID int
AS
SELECT...
FROM...
WHERE...
FOR XML AUTO, ELEMENTS
GO

I then call the procedure like this
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim Param1
Dim ID As Integer
Dim provstr As String
Dim myfrm As Form
Dim dbs As Database
Set dbs = CurrentDb()
ID = Me.ID

cn.Provider = "sqloledb"
provstr = "Server=Server1;Database=TestDB;Trusted_Connection= Yes"
cn.Open provstr

Set cmd.ActiveConnection = cn
cmd.CommandText = "dbo.procGenerateXML"
cmd.CommandType = adCmdStoredProc
Set Param1 = cmd.CreateParameter("Input", adInteger, adParamInput)
cmd.Parameters.Append Param1
Param1.Value = ID
Set rs = cmd.Execute

I'm looking for guidance on the following:

-Can I use this xp_cmdshell method without giving my end users execute
permissions on xp_cmdshell and if not;
-Are there alternatives that don't use xp_cmdshell

Thanks|||Terri (terri@.cybernets.com) writes:
>> This is not likely to work very well. ODBC will chop the XML document
>> after each 2033 character. See KB 275583.
>>
>> So you would need to get the XML document to the client, and have the
>> client to create the file and put it where it belongs. Which probably
>> is better from a security perspective as well.
> Thanks Erland,
> I'm not using Query Analyzer so I don't think KB 275583 applies to me.

But you are using BCP which is implemented in ODBC. So I would definitely
encourage you to test to generate a large XML document, before you
ponder the issues with access to xp_cmdshell.

--
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|||If you are already calling this code from ADO, then instead of BCP and
all that you can just directly execute the FOR XML statement, loop
through each 2033 char return results and create the XML file from the
web server.

Erland Sommarskog wrote:
> Terri (terri@.cybernets.com) writes:
> >> This is not likely to work very well. ODBC will chop the XML document
> >> after each 2033 character. See KB 275583.
> >>
> >> So you would need to get the XML document to the client, and have the
> >> client to create the file and put it where it belongs. Which probably
> >> is better from a security perspective as well.
> > Thanks Erland,
> > I'm not using Query Analyzer so I don't think KB 275583 applies to me.
> But you are using BCP which is implemented in ODBC. So I would definitely
> encourage you to test to generate a large XML document, before you
> ponder the issues with access to xp_cmdshell.
>
>
> --
> 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|||pb648174 (google@.webpaul.net) writes:
> If you are already calling this code from ADO, then instead of BCP and
> all that you can just directly execute the FOR XML statement, loop
> through each 2033 char return results and create the XML file from the
> web server.

Actually, if he would do it the simple-minded way, he would not get
2033-characters slices, as he is using SQLOLEDB(*) - he would get a binary
thingie instead.

I have not investigated it, but I believe the proper way to receive FOR
XML in ADO with SQLOLEDB is to use the Stream object.

But apart from that fine detail, I agree with you. Doing this from SQL
Server will be diffictul.

(*) If you use the MSDASQL provider, that is ODBC, then you would have
to as you say. But I would not recommend that.

--
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|||Thanks to those who replied, I'm going to investigate the ADO stream object.

"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns970CB19EE5537Yazorman@.127.0.0.1...
> pb648174 (google@.webpaul.net) writes:
> > If you are already calling this code from ADO, then instead of BCP and
> > all that you can just directly execute the FOR XML statement, loop
> > through each 2033 char return results and create the XML file from the
> > web server.
> Actually, if he would do it the simple-minded way, he would not get
> 2033-characters slices, as he is using SQLOLEDB(*) - he would get a binary
> thingie instead.
> I have not investigated it, but I believe the proper way to receive FOR
> XML in ADO with SQLOLEDB is to use the Stream object.
> But apart from that fine detail, I agree with you. Doing this from SQL
> Server will be diffictul.
> (*) If you use the MSDASQL provider, that is ODBC, then you would have
> to as you say. But I would not recommend that.|||I did something like this in C# .NET recently via the native SQL OleDB
provider and had to do the looping action. I think that even when I
submitted the Query using Query Analyzer, I could see it coming back as
multiple rows... I could be wrong though.

Saturday, February 25, 2012

Need help: Openxml failed for datasize greater than 120k

Hi,
Can anybody help me on what is going wrong, please?
I tried to pass an XML document as text parameter in a stored procedure
where openxml is being used to insert data into temp tables. If I pass any
XML document over 120k of size it goes in a loop and does not return any
error message. The SQL server is 2000 standard edition with service pack 3
running on windows 2003 server and it has all the latest versions of MSXML
(version 2, 3 and 4. All with latest service packs).
However if I try to execute it in my laptop (win XP professional, MSDE 2000
with service pack 3), it works fine. I tried with 500k XML data and it can
process.
Am I missing anything?
thanks
-Asir
Message posted via http://www.webservertalk.comHi
I assume you are calling SQLXML which uses MSXML? In which case make sure
that you have download the latest service pack (sp3). Without DDL, code or
example data it is not possible diagnose this problem. Check the differences
in the structure of the small files compared to the larger ones. You may wan
t
to try posting to microsoft.public.sqlserver.xml to see if anyone there has
more to add.
John
"Asir Sikdar via webservertalk.com" wrote:

> Hi,
> Can anybody help me on what is going wrong, please?
> I tried to pass an XML document as text parameter in a stored procedure
> where openxml is being used to insert data into temp tables. If I pass any
> XML document over 120k of size it goes in a loop and does not return any
> error message. The SQL server is 2000 standard edition with service pack 3
> running on windows 2003 server and it has all the latest versions of MSXML
> (version 2, 3 and 4. All with latest service packs).
> However if I try to execute it in my laptop (win XP professional, MSDE 200
0
> with service pack 3), it works fine. I tried with 500k XML data and it can
> process.
> Am I missing anything?
> thanks
> -Asir
> --
> Message posted via http://www.webservertalk.com
>|||My Code block is given below: From front end, ASP.Net(C#) I passed the XML
document as text to the stored procedure.
CREATE PROCEDURE p_xmlinsert
@.RequestId As Int,
@.Data1 As Int,
@.doc As text
As
Begin
Declare @.idoc Int
Declare @.TranCount Int,
@.Msg Varchar(256)
Set @.Msg = 'OK'
Set @.TranCount = @.@.TRANCOUNT
Exec sp_xml_preparedocument @.idoc OUTPUT, @.doc
SELECT *
Into #Tmp1
FROM OPENXML (@.idoc, '/Data/Invoice',2)
WITH
( InvoiceNumber VarChar(64) '@.Invoice_Number',
Data1 Int '@.Data1',
Adderess1 VarChar(32) '@.Adder1',
Adderess2 VarChar(32) '@.Adder2',
City VarChar(32) '@.City',
State VarChar(32) '@.State',
Zip VarChar(32) '@.Zip',
Date VarChar(32) '@.Date',
Total VarChar(32) '@.Total'
)
SELECT *
Into #Tmp2
FROM OPENXML (@.idoc, '/Data/Invoice/Event',2)
WITH
( InvoiceNumber VarChar(64) '../@.Invoice_Number',
OrderNumber VarChar(32) '@.Order_Number',
OrderDate DateTime '@.Order_Date',
ContactName VarChar(64) '@.Contact_Name',
ContactEmail VarChar(64) '@.Contact_Email',
ContactPhone VarChar(24) '@.Contact_Phone',
ContactAddr1 VarChar(128) '@.Contact_Addr1',
ContactAddr2 VarChar(128) '@.Contact_Addr2',
ContactCity VarChar(32) '@.Contact_City',
ContactState VarChar(2) '@.Contact_State',
ContactZip VarChar(5) '@.Contact_Zip',
)
SELECT *
Into #Tmp3
FROM OPENXML (@.idoc, '/Data/Invoice/Event/Order_Detail',2)
WITH
(InvoiceNumber VarChar(64) '../../@.Invoice_Number',
OrderNumber VarChar(32) '../@.Order_Number',
ItemName VarChar(64) '@.Item_Name',
ItemDesc VarChar(256) '@.Item_Desc',
Quantity Decimal(18,2) '@.Quantity',
UnitPrice Decimal(18,2) '@.Unit_Price',
OrderTax Decimal(18,2) '@.Order_Tax',
OrderTotal Decimal(18,2) '@.Order_Total'
)
EXECUTE sp_xml_removedocument @.idoc
--Now Add data
If @.TranCount = 0
Begin Tran
Insert Into table1
(
ReqId,
Data1,
InvoiceNumber,
UnitAddress1,
UnitAddress2,
UnitCity,
UnitState,
UnitZip,
InvoiceDate,
InvoiceNetAmount,
InvoiceTaxAmount,
InvoiceTotalAmount,
CreatedDate
)
Select
@.RequestId,
Data1,
InvoiceNumber,
UnitAdder1,
UnitAdder2,
UnitCity,
UnitState,
UnitZip,
InvoiceDate,
0.0,
0.0,
Total,
GetDate()
From #Tmp1
If @.@.error<>0
Begin
Set @.Msg = 'Error: Insert1 failed!'
RAISERROR (@.Msg, 16, 1)
If @.TranCount = 0
Rollback Transaction
Select 0
Return
End
Insert Into table2
(
Table1Id,
OrderNumber,
OrderDate,
ContactName,
ContactEmail,
ContactPhone,
ContactAddress1,
ContactAddress2,
ContactCity,
ContactState,
ContactZip,
)
Select A.Table1Id,
OrderNumber,
OrderDate,
ContactName,
ContactEmail,
ContactPhone,
ContactAddr1,
ContactAddr2,
ContactCity,
ContactState,
ContactZip,
From #Tmp2 A,
Table1 B
Where A.InvoiceNumber = B.InvoiceNumber
And B.Data1 = @.Data1
And B.ReqId = @.RequestId
If @.@.error<>0
Begin
Set @.Msg = 'Error: Insert2 failed!'
RAISERROR (@.Msg, 16, 1)
If @.TranCount = 0
Rollback Transaction
Select 0
Return
End
Insert Into Table3
(
Table2Id,
ItemName,
ItemDescription,
Quantity,
UnitPrice,
SalesTax,
TotalPrice
)
Select B.Table2Id,
ItemName,
ItemDesc,
Quantity,
UnitPrice,
OrderTax,
OrderTotal
From #Tmp3 A,
Table1 B,
Table2 C
Where A.InvoiceNumber = B.InvoiceNumber
And B.Data1 = @.Data1
And B.ReqId = @.RequestId
And A.OrderNumber = C.OrderNumber
And B.Table1Id = C.Table1Id
If @.@.error<>0
Begin
Set @.Msg = 'Error: Insert3 failed!'
RAISERROR (@.Msg, 16, 1)
If @.TranCount = 0
Rollback Transaction
Select 0
Return
End
Update TableQueue Set Status = 'Ready' Where ReqId = @.RequestId and Status
= 'Pending'
If @.@.error<>0
Begin
Set @.Msg = 'Error: Update failed!'
RAISERROR (@.Msg, 16, 1)
If @.TranCount = 0
Rollback Transaction
Select 0
Return
End
If @.TranCount = 0
Commit Transaction
Select 3
Return
End
GO
Thanks
-Asir
Message posted via http://www.webservertalk.com

Monday, February 20, 2012

Need Help with XML Schema for Bulkload

I've been struggling for days trying to create an XML View/Schema mapped to
SQL Server to import a relatively straightforward XML document into a simple
(only two tables) SQL Server database. The examples I've seen do not seem to
address cases where some XML elements do not contribute to the population of
the database. And I keep getting errors "needs a relationship" even when I
add relationships. I also want SQL Server to handle the identity columns and
so I set KeepIdentity to False.
So, can anyone help or direct me to examples that could help me understand
the issues. I'm Googled out. Thanks.
XML Document
<pregnancies>
<pregnancy>
<summary>
<firstName>Jane</firstName>
<lastName>Doe</lastName>
<dob>7/22/85</dob>
</summary>
<facts>
<fact>
<factDate>3/3/07</factDate>
<factName>Eye Color</factName>
<factValue>Brown</factValue>
</fact>
<fact>
<factDate>6/6/07</factDate>
<factName>Hair Color</factName>
<factValue>Brown</factValue>
</fact>
</facts>
</pregnancy>
<pregnancy>
<summary>
<firstName>Mary</firstName>
<lastName>Smith</lastName>
<dob>6/12/85</dob>
</summary>
<facts>
<fact>
<factDate>3/3/07</factDate>
<factName>Eye Color</factName>
<factValue>Blue</factValue>
</fact>
<fact>
<factDate>6/6/07</factDate>
<factName>Hair Color</factName>
<factValue>Blonde</factValue>
</fact>
</facts>
</pregnancy>
</pregnancies>
Target Database Tables
Pregnancies
PregnancyID
FirstName
LastName
DateOfBirth
PregnancyFacts
PregnancyFactID
PregnancyID (FK)
FactDate
FactName
FactValue
I ran across this on the web
(http://www.topxml.com/sqlxml/using_sqlxmladapter_in_dotnet.asp)
"On the negative side Bulk Load also cannot handle nested types where
children require the IDENTITY of the parent as a foreign key."
I think this is exactly what I was trying to do. For each <Pregnancy>,
automatically generate a PregnancyID identity column, and then use that
PregnancyID in all the PregnancyFacts associated with that pregnancy.
I chose SQLXML Bulkload because I am trying to import millions of elements
into a database.
Is the statement above true for v4.0? How else can I import very large XML
files and tag all PregnancyFacts with a single PregnancyID for each
pregnancy?
Thanks for any help and direction.
"Don Miller" <nospam@.nospam.com> wrote in message
news:Oiyb6DynHHA.4412@.TK2MSFTNGP02.phx.gbl...
> I've been struggling for days trying to create an XML View/Schema mapped
> to SQL Server to import a relatively straightforward XML document into a
> simple (only two tables) SQL Server database. The examples I've seen do
> not seem to address cases where some XML elements do not contribute to the
> population of the database. And I keep getting errors "needs a
> relationship" even when I add relationships. I also want SQL Server to
> handle the identity columns and so I set KeepIdentity to False.
> So, can anyone help or direct me to examples that could help me understand
> the issues. I'm Googled out. Thanks.
> XML Document
> --
> <pregnancies>
> <pregnancy>
> <summary>
> <firstName>Jane</firstName>
> <lastName>Doe</lastName>
> <dob>7/22/85</dob>
> </summary>
> <facts>
> <fact>
> <factDate>3/3/07</factDate>
> <factName>Eye Color</factName>
> <factValue>Brown</factValue>
> </fact>
> <fact>
> <factDate>6/6/07</factDate>
> <factName>Hair Color</factName>
> <factValue>Brown</factValue>
> </fact>
> </facts>
> </pregnancy>
> <pregnancy>
> <summary>
> <firstName>Mary</firstName>
> <lastName>Smith</lastName>
> <dob>6/12/85</dob>
> </summary>
> <facts>
> <fact>
> <factDate>3/3/07</factDate>
> <factName>Eye Color</factName>
> <factValue>Blue</factValue>
> </fact>
> <fact>
> <factDate>6/6/07</factDate>
> <factName>Hair Color</factName>
> <factValue>Blonde</factValue>
> </fact>
> </facts>
> </pregnancy>
> </pregnancies>
> Target Database Tables
> --
> Pregnancies
> --
> PregnancyID
> FirstName
> LastName
> DateOfBirth
> PregnancyFacts
> --
> PregnancyFactID
> PregnancyID (FK)
> FactDate
> FactName
> FactValue
>
|||Hello,
I came up with the following schema based on your xml data:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<sql:relationship name="PPF"
parent="Pregnancies"
child="PregnancyFacts"
parent-key="PregnancyID"
child-key="PregnancyID"/>
</xs:appinfo>
</xs:annotation>
<xs:element name="pregnancies" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="pregnancy" sql:relation="Pregnancies">
<xs:complexType>
<xs:sequence>
<xs:element name="summary" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" sql:field="FirstName"
type="xs:string"/>
<xs:element name="lastName" sql:field="LastName" type="xs:string"/>
<xs:element name="dob" sql:field="DateOfBirth" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="facts" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="fact" sql:relation="PregnancyFacts"
sql:relationship="PPF">
<xs:complexType>
<xs:sequence>
<xs:element name="factDate" sql:field="FactDate" type="xs:date"/>
<xs:element name="factName" sql:field="FactName"
type="xs:string"/>
<xs:element name="factValue" sql:field="FactValue"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I bulkload using this schema and the xml data below I got the folloing
inserted in the tables:
PregnancyID FirstName LastName DateOfBirth
-- -- -- --
1 Jane Doe 1985-07-22 00:00:00.000
2 Mary Smith 1985-06-12 00:00:00.000
(2 row(s) affected)
PregnancyFactID PregnancyID FactDate FactName FactValue
-- -- -- -- --
1 1 2007-03-03 00:00:00.000 Eye Color Brown
2 1 2007-06-06 00:00:00.000 Hair Color Brown
3 2 2007-03-03 00:00:00.000 Eye Color Blue
4 2 2007-06-06 00:00:00.000 Hair Color Blonde
(4 row(s) affected)
Identity values will be propagated from the parent to the child tables.
I hope this solves your problem.
Best regards,
Monica Frintu
"Don Miller" wrote:

> I ran across this on the web
> (http://www.topxml.com/sqlxml/using_sqlxmladapter_in_dotnet.asp)
> "On the negative side Bulk Load also cannot handle nested types where
> children require the IDENTITY of the parent as a foreign key."
> I think this is exactly what I was trying to do. For each <Pregnancy>,
> automatically generate a PregnancyID identity column, and then use that
> PregnancyID in all the PregnancyFacts associated with that pregnancy.
> I chose SQLXML Bulkload because I am trying to import millions of elements
> into a database.
> Is the statement above true for v4.0? How else can I import very large XML
> files and tag all PregnancyFacts with a single PregnancyID for each
> pregnancy?
> Thanks for any help and direction.
>
> "Don Miller" <nospam@.nospam.com> wrote in message
> news:Oiyb6DynHHA.4412@.TK2MSFTNGP02.phx.gbl...
>
>

Need Help with XML Schema for Bulkload

I've been struggling for days trying to create an XML View/Schema mapped to
SQL Server to import a relatively straightforward XML document into a simple
(only two tables) SQL Server database. The examples I've seen do not seem to
address cases where some XML elements do not contribute to the population of
the database. And I keep getting errors "needs a relationship" even when I
add relationships. I also want SQL Server to handle the identity columns and
so I set KeepIdentity to False.
So, can anyone help or direct me to examples that could help me understand
the issues. I'm Googled out. Thanks.
XML Document
--
<pregnancies>
<pregnancy>
<summary>
<firstName>Jane</firstName>
<lastName>Doe</lastName>
<dob>7/22/85</dob>
</summary>
<facts>
<fact>
<factDate>3/3/07</factDate>
<factName>Eye Color</factName>
<factValue>Brown</factValue>
</fact>
<fact>
<factDate>6/6/07</factDate>
<factName>Hair Color</factName>
<factValue>Brown</factValue>
</fact>
</facts>
</pregnancy>
<pregnancy>
<summary>
<firstName>Mary</firstName>
<lastName>Smith</lastName>
<dob>6/12/85</dob>
</summary>
<facts>
<fact>
<factDate>3/3/07</factDate>
<factName>Eye Color</factName>
<factValue>Blue</factValue>
</fact>
<fact>
<factDate>6/6/07</factDate>
<factName>Hair Color</factName>
<factValue>Blonde</factValue>
</fact>
</facts>
</pregnancy>
</pregnancies>
Target Database Tables
--
Pregnancies
--
PregnancyID
FirstName
LastName
DateOfBirth
PregnancyFacts
--
PregnancyFactID
PregnancyID (FK)
FactDate
FactName
FactValueI ran across this on the web
(http://www.topxml.com/sqlxml/using_...r_in_dotnet.asp)
"On the negative side Bulk Load also cannot handle nested types where
children require the IDENTITY of the parent as a foreign key."
I think this is exactly what I was trying to do. For each <Pregnancy>,
automatically generate a PregnancyID identity column, and then use that
PregnancyID in all the PregnancyFacts associated with that pregnancy.
I chose SQLXML Bulkload because I am trying to import millions of elements
into a database.
Is the statement above true for v4.0? How else can I import very large XML
files and tag all PregnancyFacts with a single PregnancyID for each
pregnancy?
Thanks for any help and direction.
"Don Miller" <nospam@.nospam.com> wrote in message
news:Oiyb6DynHHA.4412@.TK2MSFTNGP02.phx.gbl...
> I've been struggling for days trying to create an XML View/Schema mapped
> to SQL Server to import a relatively straightforward XML document into a
> simple (only two tables) SQL Server database. The examples I've seen do
> not seem to address cases where some XML elements do not contribute to the
> population of the database. And I keep getting errors "needs a
> relationship" even when I add relationships. I also want SQL Server to
> handle the identity columns and so I set KeepIdentity to False.
> So, can anyone help or direct me to examples that could help me understand
> the issues. I'm Googled out. Thanks.
> XML Document
> --
> <pregnancies>
> <pregnancy>
> <summary>
> <firstName>Jane</firstName>
> <lastName>Doe</lastName>
> <dob>7/22/85</dob>
> </summary>
> <facts>
> <fact>
> <factDate>3/3/07</factDate>
> <factName>Eye Color</factName>
> <factValue>Brown</factValue>
> </fact>
> <fact>
> <factDate>6/6/07</factDate>
> <factName>Hair Color</factName>
> <factValue>Brown</factValue>
> </fact>
> </facts>
> </pregnancy>
> <pregnancy>
> <summary>
> <firstName>Mary</firstName>
> <lastName>Smith</lastName>
> <dob>6/12/85</dob>
> </summary>
> <facts>
> <fact>
> <factDate>3/3/07</factDate>
> <factName>Eye Color</factName>
> <factValue>Blue</factValue>
> </fact>
> <fact>
> <factDate>6/6/07</factDate>
> <factName>Hair Color</factName>
> <factValue>Blonde</factValue>
> </fact>
> </facts>
> </pregnancy>
> </pregnancies>
> Target Database Tables
> --
> Pregnancies
> --
> PregnancyID
> FirstName
> LastName
> DateOfBirth
> PregnancyFacts
> --
> PregnancyFactID
> PregnancyID (FK)
> FactDate
> FactName
> FactValue
>|||Hello,
I came up with the following schema based on your xml data:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:appinfo>
<sql:relationship name="PPF"
parent="Pregnancies"
child="PregnancyFacts"
parent-key="PregnancyID"
child-key="PregnancyID"/>
</xs:appinfo>
</xs:annotation>
<xs:element name="pregnancies" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="pregnancy" sql:relation="Pregnancies">
<xs:complexType>
<xs:sequence>
<xs:element name="summary" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="firstName" sql:field="FirstName"
type="xs:string"/>
<xs:element name="lastName" sql:field="LastName" type="xs:string"/>
<xs:element name="dob" sql:field="DateOfBirth" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="facts" sql:is-constant="true">
<xs:complexType>
<xs:sequence>
<xs:element name="fact" sql:relation="PregnancyFacts"
sql:relationship="PPF">
<xs:complexType>
<xs:sequence>
<xs:element name="factDate" sql:field="FactDate" type="xs:date"/>
<xs:element name="factName" sql:field="FactName"
type="xs:string"/>
<xs:element name="factValue" sql:field="FactValue"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I bulkload using this schema and the xml data below I got the folloing
inserted in the tables:
PregnancyID FirstName LastName DateOfBirth
-- -- -- --
1 Jane Doe 1985-07-22 00:00:00.000
2 Mary Smith 1985-06-12 00:00:00.000
(2 row(s) affected)
PregnancyFactID PregnancyID FactDate FactName FactValue
-- -- -- -- --
1 1 2007-03-03 00:00:00.000 Eye Color Brown
2 1 2007-06-06 00:00:00.000 Hair Color Brown
3 2 2007-03-03 00:00:00.000 Eye Color Blue
4 2 2007-06-06 00:00:00.000 Hair Color Blonde
(4 row(s) affected)
Identity values will be propagated from the parent to the child tables.
I hope this solves your problem.
Best regards,
Monica Frintu
"Don Miller" wrote:

> I ran across this on the web
> (http://www.topxml.com/sqlxml/using_...r_in_dotnet.asp)
> "On the negative side Bulk Load also cannot handle nested types where
> children require the IDENTITY of the parent as a foreign key."
> I think this is exactly what I was trying to do. For each <Pregnancy>,
> automatically generate a PregnancyID identity column, and then use that
> PregnancyID in all the PregnancyFacts associated with that pregnancy.
> I chose SQLXML Bulkload because I am trying to import millions of elements
> into a database.
> Is the statement above true for v4.0? How else can I import very large XML
> files and tag all PregnancyFacts with a single PregnancyID for each
> pregnancy?
> Thanks for any help and direction.
>
> "Don Miller" <nospam@.nospam.com> wrote in message
> news:Oiyb6DynHHA.4412@.TK2MSFTNGP02.phx.gbl...
>
>

Need help with XML output to file

I'm using SQL Server 2005 / 9.0.3042

I'm not new to sql server, but making my first experience with xml in sql server 2005.

I have a query like this (based on <Table> with neccessary data):

SELECT TAG, PARENT, <columns...>

FROM <Table>

FOR XML EXPLICIT

This query creates a xml file exactly as i need it when i execute it in Management Studio. Well, with one exception. It does not write the <xml...> tag at the beginning of the xml file. But i'm sure i get that in there somewho else. What i need to do now is get that output to a file on disk. And that's where my problem starts.

I tried SQLCMD within Management Studio, but that doesn't accept the ':XML ON' tag and ignores it. the resulting file written is not usable, as it also contains query summary information.

Any direction would be greatly appreciated!

Have you given DTS/SSIS a try. If you are having to do this procedure often, I would go with one of those.

|||

I could not find any way to choose xml as the destination for ssis. Could you give me a start on how to go on?

|||Hi Danny,
As you said that you are facing this problem in sql2005, so can u please tell me the querry by which i can generate a xml file through table in sql2000,
My basic question to you is,
HOW TO GENERATE AN XML FILE USING A SQL QUERY IN QUERY ANALYZER.?
is it possible.|||

Hi Prashant,

There are various ways to create a xml file. In general, u create a select statement and use "FOR XML xxxxx" at the end. Please have a look in Books Online for the possible <xxxxxx>. I would say it depends on purpose u want to achieve, you would choose the appropriate <xxxxxx> method. For each method u need to have its own data base.

I for my case needed to choose the FOR XML EXPLICIT method, as i need to reproduce a specific xml file dynamically, based on certain data. Running the query will create a xml file and give it as the result, so i can open it, and if i need copy the content. If "FOR XML EXPLICIT" is your choice, here is a simple example. I haven't done much on the other <xxxxxx> methods, so i'm sorry i won't be much of help. Method FOR XML EXPLICIT is the most time consuming way, but it gives almost every control to produce exactly the xml file needed.

OK: Here the sample for FOR XML EXPLICIT:

Let's suppose we need a xml file like this:

<Order>

<OrderItem Title="book1" Price="250.00"/>

<OrderItem Title="book2" Price="15.75" Discount=5.00/>

</Order>

For this we need to create a table holding the data to create the xml file using FOR XML EXPLICIT. This table must look like this: In the vertical it will have 1 row for ea line in the xml file. in the horizontal it needs the sum of all possible attributes. Enter a value will print the value in the xml file, enter empty string will print empty string in xml file, enter NULL as value will remove the attribute in the xml file. The table also needs the informatione to tell FOR XML EXPLICIT how the hierachy of the xml file must be. That is done using the TAG and PARENT attribut. The columns in the table must exactly match the names of the elements and attributes in the xml file, plus the level (number between - see blow).

Ok, here is the table:

TAG PARENT [Order!1] [OrderItem!2!Title] [OrderItem!2!Prive] [OrderItem!2!Discount]

-

1 NULL '' NULL NULL NULL

2 1 NULL book1 250.00 NULL

3 1 NULL book2 15.75 5.00

-

This is only a very simple example of FOR XML EXPLICIT, but i hope it makes clear on how it works. I used this way to generate our xml files dynamically. It was much work to build the system, but gives me much flexibility to construct all the various different xml files. Last but not least, it's only useful if the structure of the xml file don't change so often.

Need help with XML output to file

I'm using SQL Server 2005 / 9.0.3042

I'm not new to sql server, but making my first experience with xml in sql server 2005.

I have a query like this (based on <Table> with neccessary data):

SELECT TAG, PARENT, <columns...>

FROM <Table>

FOR XML EXPLICIT

This query creates a xml file exactly as i need it when i execute it in Management Studio. Well, with one exception. It does not write the <xml...> tag at the beginning of the xml file. But i'm sure i get that in there somewho else. What i need to do now is get that output to a file on disk. And that's where my problem starts.

I tried SQLCMD within Management Studio, but that doesn't accept the ':XML ON' tag and ignores it. the resulting file written is not usable, as it also contains query summary information.

Any direction would be greatly appreciated!

Have you given DTS/SSIS a try. If you are having to do this procedure often, I would go with one of those.

|||

I could not find any way to choose xml as the destination for ssis. Could you give me a start on how to go on?

|||Hi Danny,
As you said that you are facing this problem in sql2005, so can u please tell me the querry by which i can generate a xml file through table in sql2000,
My basic question to you is,
HOW TO GENERATE AN XML FILE USING A SQL QUERY IN QUERY ANALYZER.?
is it possible.|||

Hi Prashant,

There are various ways to create a xml file. In general, u create a select statement and use "FOR XML xxxxx" at the end. Please have a look in Books Online for the possible <xxxxxx>. I would say it depends on purpose u want to achieve, you would choose the appropriate <xxxxxx> method. For each method u need to have its own data base.

I for my case needed to choose the FOR XML EXPLICIT method, as i need to reproduce a specific xml file dynamically, based on certain data. Running the query will create a xml file and give it as the result, so i can open it, and if i need copy the content. If "FOR XML EXPLICIT" is your choice, here is a simple example. I haven't done much on the other <xxxxxx> methods, so i'm sorry i won't be much of help. Method FOR XML EXPLICIT is the most time consuming way, but it gives almost every control to produce exactly the xml file needed.

OK: Here the sample for FOR XML EXPLICIT:

Let's suppose we need a xml file like this:

<Order>

<OrderItem Title="book1" Price="250.00"/>

<OrderItem Title="book2" Price="15.75" Discount=5.00/>

</Order>

For this we need to create a table holding the data to create the xml file using FOR XML EXPLICIT. This table must look like this: In the vertical it will have 1 row for ea line in the xml file. in the horizontal it needs the sum of all possible attributes. Enter a value will print the value in the xml file, enter empty string will print empty string in xml file, enter NULL as value will remove the attribute in the xml file. The table also needs the informatione to tell FOR XML EXPLICIT how the hierachy of the xml file must be. That is done using the TAG and PARENT attribut. The columns in the table must exactly match the names of the elements and attributes in the xml file, plus the level (number between - see blow).

Ok, here is the table:

TAG PARENT [Order!1] [OrderItem!2!Title] [OrderItem!2!Prive] [OrderItem!2!Discount]

-

1 NULL '' NULL NULL NULL

2 1 NULL book1 250.00 NULL

3 1 NULL book2 15.75 5.00

-

This is only a very simple example of FOR XML EXPLICIT, but i hope it makes clear on how it works. I used this way to generate our xml files dynamically. It was much work to build the system, but gives me much flexibility to construct all the various different xml files. Last but not least, it's only useful if the structure of the xml file don't change so often.

Need help with XML Bulk Load

I have a source xml file which I think is fairly complex. It s an EDIFACT
D96A INVRPT file.
I just need to bring the data within into a single table
CREATE TABLE InventoryOnHand (
InventoryDate nvarchar(10) DEFAULT (getdate()),
Barcode nvarchar(50),
Quantity float,
Warehouse nvarchar(50)
)
I've been fiddling with creating a schema to read the data, but I keep
getting various errors.
If anyone wants to help, let me know & I'll email you a sample source file
and my attempts at a schema. I'm getting desperate - I've spent so many
hours mucking around I'm at the end of my tether, so any assistance is
greatly appreciated!
cheers
DannyPlease send me your files and I'll take a look.
Regards,
--
Monica Frintu
"dc" wrote:

> I have a source xml file which I think is fairly complex. It s an EDIFACT
> D96A INVRPT file.
> I just need to bring the data within into a single table
> CREATE TABLE InventoryOnHand (
> InventoryDate nvarchar(10) DEFAULT (getdate()),
> Barcode nvarchar(50),
> Quantity float,
> Warehouse nvarchar(50)
> )
> I've been fiddling with creating a schema to read the data, but I keep
> getting various errors.
> If anyone wants to help, let me know & I'll email you a sample source file
> and my attempts at a schema. I'm getting desperate - I've spent so many
> hours mucking around I'm at the end of my tether, so any assistance is
> greatly appreciated!
> cheers
> Danny
>
>|||Monica,
Thanks for your offer. You can you ensure your email address is correct -
I'm getting NDRs.
cheers
Danny
dannyc@.accolade.com.au
"Monica Frintu [MSFT]" <MonicaFrintuMSFT@.discussions.microsoft.com> wrote in
message news:66FD8513-C76B-48B1-80AC-7BD50ED994F1@.microsoft.com...
> Please send me your files and I'll take a look.
> Regards,
> --
> Monica Frintu
>
> "dc" wrote:
>|||Monica,
This might help instead
My table is thus:
CREATE TABLE AA_InventoryOnHand (
InventoryDate nvarchar(10),
Barcode nvarchar(50) ,
Quantity float
)
My sample XML file is long, but copying to notepad and saving as
V3_INVRPT.XML should help someone to diagnose. Go down to the
============== line
<?xml version="1.0" encoding="UTF-8"?>
<EDIFACT_D96A_INVRPT xmlns="http://holoncorp.com/xml/EDIFACT/D96A/INVRPT"
xmlns:v3="http://holoncorp.com/xml/EDIFACT/D96A/INVRPT">
<UNB UNB010_0001_syntaxIndentifier="UNOA" UNB010_0002_syntaxVersion="3"
UNB020_0004_senderIdentification="VISA Sydney"
UNB020_0007_partnerIdentificationCodeQua
lifier="ZZ"
UNB030_0007_partnerIdentificationCodeQua
lifier="ZZ"
UNB030_0010_recipientIdentification="Barilla"
UNB040_0017_dateOfPreparation="070510" UNB040_0019_timeOfPreparation="1017"
UNB050_0020_interchangeControlReference=
"1020"/>
<INVRPT>
<UNH UNH010_0062_referenceNumber="0001" UNH020_0051_controllingAgency="UN"
UNH020_0052_versionNumber="D" UNH020_0054_releaseNumber="96A"
UNH020_0057_associationAssignedCode="EAN005"
UNH020_0065_typeIdentifier="INVRPT"/>
<BGM BGM010_1001_messageName="35" BGM020_1004_messageNumber="1020"
BGM030_1225_messageFunction="9"/>
<DTM DTM010_2005_dateTimePeriodQualifier="366"
DTM010_2379_dateTimePeriodFormatQualifie
r="102"
DTM010_2380_dateTimePeriod="20070510"/>
<GRP2>
<NAD NAD010_3035_partyQualifier="GY" NAD020_3039_partyIdIdentification="VISA
Sydney" NAD020_3055_codeListResponsibleAgency="86"/>
<GRP4>
<CTA CTA010_3139_contactFunctionCode="WH"
CTA020_3412_departmentOrEmployeeName="Jim Vikas"/>
<COM COM010_3148_communicationAddressIdentifi
er=""
COM020_3155_communicationAddressQualifie
r="TE"/>
<COM COM010_3148_communicationAddressIdentifi
er=""
COM020_3155_communicationAddressQualifie
r="EM"/>
</GRP4>
</GRP2>
<GRP2>
<NAD NAD010_3035_partyQualifier="GM"
NAD020_3039_partyIdIdentification="Cantarella"
NAD020_3055_codeListResponsibleAgency="86"/>
</GRP2>
<GRP9>
<LIN LIN030_7140_itemNumber="841158000029"
LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="144" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="841158000043"
LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="166" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="2" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="AZZURRA" LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="1000" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="30" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="fab" LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="10" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="1" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
<GIN GIN010_7405_identityNumberQualifier="BX"
GIN020_7402_identityNumberRange="13"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="fab" LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="100" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="20" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
<GIN GIN010_7405_identityNumberQualifier="BX"
GIN020_7402_identityNumberRange="12"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="INSTANT" LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="1000" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="30" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="KING OSCAR"
LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="1000" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="40" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<GRP9>
<LIN LIN030_7140_itemNumber="sard brisling"
LIN030_7143_itemNumberTypeCode="EN"/>
<GRP12>
<INV INV040_4503_inventoryBalanceMethodCode="1"/>
<QTY QTY010_6060_quantity="1000" QTY010_6063_quantityQualifier="17"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="30" QTY010_6063_quantityQualifier="170"
QTY010_6411_measurementUnitCode="EA"/>
<QTY QTY010_6060_quantity="0" QTY010_6063_quantityQualifier="253"
QTY010_6411_measurementUnitCode="EA"/>
</GRP12>
</GRP9>
<UNT UNT010_0074_numberOfSegments="54" UNT020_0062_referenceNumber="0001"/>
</INVRPT>
<UNZ UNZ010_0020_interchangeControlReference=
"1020"
UNZ010_0036_interchangeControlCount="1"/>
</EDIFACT_D96A_INVRPT>
=======================
And here is the schema file I've written.
<?xml version="1.0" ?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schemas-microsoft-com:xml:datatypes"
xmlns:sql="urn:schemas-microsoft-com:xml-sql" >
<ElementType name="EDIFACT_D96A_INVRPT" sql:is-constant="1">
<element type="UNB" />
<element type="LIN" />
<element type="QTY" />
</ElementType>
<ElementType name="UNB" sql:relation="AA_InventoryOnHand" >
<AttributeType name="UNB040_0017_dateOfPreparation" dt:type="string"
/>
<attribute type="UNB040_0017_dateOfPreparation"
sql:field="InventoryDate" />
</ElementType>
<ElementType name="LIN" sql:relation="AA_InventoryOnHand" >
<AttributeType name="LIN030_7140_itemNumber" dt:type="string" />
<attribute type="LIN030_7140_itemNumber" sql:field="Barcode" />
</ElementType>
<ElementType name="QTY" sql:relation="AA_InventoryOnHand" >
<AttributeType name="QTY010_6060_quantity" dt:type="float" />
<attribute type="QTY010_6060_quantity" sql:field="Quantity" />
</ElementType>
</Schema>
==============================
And here's a vbs file I'm running
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkLoad")
objBL.ConnectionString = "provider=SQLOLEDB.1;data
source=DANNYCVM;database=MyDemoDB;uid=sa
;pwd=MysaPassword"
objBL.ErrorLogFile = "c:\error.log"
objBL.Execute "c:\Invmapping.xml", "c:\V3_INVRPT.xml"
Set objBL = Nothing
=============================
The table should be populated thus:
070510 841158000029 144
070510 841158000043 166
070510 841158000043 2
etc
"dc" <dannyc@.accoalde.com.au> wrote in message
news:uns4XWxkHHA.1624@.TK2MSFTNGP06.phx.gbl...
>I have a source xml file which I think is fairly complex. It s an EDIFACT
>D96A INVRPT file.
> I just need to bring the data within into a single table
> CREATE TABLE InventoryOnHand (
> InventoryDate nvarchar(10) DEFAULT (getdate()),
> Barcode nvarchar(50),
> Quantity float,
> Warehouse nvarchar(50)
> )
> I've been fiddling with creating a schema to read the data, but I keep
> getting various errors.
> If anyone wants to help, let me know & I'll email you a sample source file
> and my attempts at a schema. I'm getting desperate - I've spent so many
> hours mucking around I'm at the end of my tether, so any assistance is
> greatly appreciated!
> cheers
> Danny
>