Showing posts with label import. Show all posts
Showing posts with label import. Show all posts

Friday, March 30, 2012

Help with SQL Mapping

First time trying to import a pretty simple XML file into a SQL
table. I've been reading annotated XSD file docs for the past 3 hours
and it's just not clear to me. Here's my XML
<?xml version="1.0" standalone="yes"?>
<InvoiceBalanceData>
<InvoiceBalanceData>
<documentnumber>12345</documentnumber>
<invoicebalance>99.99</invoicebalance>
<invoicenumber>INV123</invoicenumber>
<invoicetrantype>FS</invoicetrantype>
</InvoiceBalanceData>
<InvoiceBalanceData>
<documentnumber>444</documentnumber>
<invoicebalance>88.88</invoicebalance>
<invoicenumber>INV345</invoicenumber>
<invoicetrantype>AB</invoicetrantype>
</InvoiceBalanceData>
</InvoiceBalanceData>
Can someone help me with my annotated XSD file? tia.
On Dec 13, 10:31 am, Larry Bud <larrybud2...@.yahoo.com> wrote:
> First time trying to import a pretty simple XML file into a SQL
> table. I've been reading annotated XSD file docs for the past 3 hours
> and it's just not clear to me. Here's my XML
> <?xml version="1.0" standalone="yes"?>
> <InvoiceBalanceData>
> <InvoiceBalanceData>
> <documentnumber>12345</documentnumber>
> <invoicebalance>99.99</invoicebalance>
> <invoicenumber>INV123</invoicenumber>
> <invoicetrantype>FS</invoicetrantype>
> </InvoiceBalanceData>
> <InvoiceBalanceData>
> <documentnumber>444</documentnumber>
> <invoicebalance>88.88</invoicebalance>
> <invoicenumber>INV345</invoicenumber>
> <invoicetrantype>AB</invoicetrantype>
> </InvoiceBalanceData>
> </InvoiceBalanceData>
> Can someone help me with my annotated XSD file? tia.
I should add that after I attempt to import the XML, the script
finishes successfully (this is from a DTS package), but no rows are
imported into the table.
|||I would process it as attribute centric
declare @.xml xml
SET @.xml =
'<root>
<InvoiceBalanceData documentnumber="12345" invoicebalance="99.99"
invoicenumber="INV123" invoicetrantype="FS" />
<InvoiceBalanceData documentnumber="444" invoicebalance="88.88"
invoicenumber="INV345" invoicetrantype="AB" />
</root>'
select @.xml
SELECT
[inv].[ref].value('@.documentnumber', 'int'),
[inv].[ref].value('@.invoicebalance', 'money')
FROM @.xml.nodes('/root/InvoiceBalanceData') [inv]([ref])
See SQL Server BOL as well.
-- Create tables for later population using OPENXML.
CREATE TABLE Customers (CustomerID varchar(20) primary key,
ContactName varchar(20),
CompanyName varchar(20))
GO
CREATE TABLE Orders( CustomerID varchar(20), OrderDate datetime)
GO
DECLARE @.docHandle int
DECLARE @.xmlDocument nvarchar(max) -- or xml type
SET @.xmlDocument = N'<ROOT>
<Customers CustomerID="XYZAA" ContactName="Joe" CompanyName="Company1">
<Orders CustomerID="XYZAA" OrderDate="2000-08-25T00:00:00"/>
<Orders CustomerID="XYZAA" OrderDate="2000-10-03T00:00:00"/>
</Customers>
<Customers CustomerID="XYZBB" ContactName="Steve"
CompanyName="Company2">No Orders yet!
</Customers>
</ROOT>'
EXEC sp_xml_preparedocument @.docHandle OUTPUT, @.xmlDocument
-- Use OPENXML to provide rowset consisting of customer data.
INSERT Customers
SELECT *
FROM OPENXML(@.docHandle, N'/ROOT/Customers')
WITH Customers
-- Use OPENXML to provide rowset consisting of order data.
INSERT Orders
SELECT *
FROM OPENXML(@.docHandle, N'//Orders')
WITH Orders
-- Using OPENXML in a SELECT statement.
SELECT * FROM OPENXML(@.docHandle, N'/ROOT/Customers/Orders') WITH
(CustomerID nchar(5) '../@.CustomerID', OrderDate datetime)
-- Remove the internal representation of the XML document.
EXEC sp_xml_removedocument @.docHandle
"Larry Bud" <larrybud2002@.yahoo.com> wrote in message
news:6ebab460-5eda-4c48-a4be-1ef478130ea3@.i29g2000prf.googlegroups.com...
> On Dec 13, 10:31 am, Larry Bud <larrybud2...@.yahoo.com> wrote:
> I should add that after I attempt to import the XML, the script
> finishes successfully (this is from a DTS package), but no rows are
> imported into the table.

Help with SQL Mapping

First time trying to import a pretty simple XML file into a SQL
table. I've been reading annotated XSD file docs for the past 3 hours
and it's just not clear to me. Here's my XML
<?xml version="1.0" standalone="yes"?>
<InvoiceBalanceData>
<InvoiceBalanceData>
<documentnumber>12345</documentnumber>
<invoicebalance>99.99</invoicebalance>
<invoicenumber>INV123</invoicenumber>
<invoicetrantype>FS</invoicetrantype>
</InvoiceBalanceData>
<InvoiceBalanceData>
<documentnumber>444</documentnumber>
<invoicebalance>88.88</invoicebalance>
<invoicenumber>INV345</invoicenumber>
<invoicetrantype>AB</invoicetrantype>
</InvoiceBalanceData>
</InvoiceBalanceData>
Can someone help me with my annotated XSD file? tia.On Dec 13, 10:31 am, Larry Bud <larrybud2...@.yahoo.com> wrote:
> First time trying to import a pretty simple XML file into a SQL
> table. I've been reading annotated XSD file docs for the past 3 hours
> and it's just not clear to me. Here's my XML
> <?xml version="1.0" standalone="yes"?>
> <InvoiceBalanceData>
> <InvoiceBalanceData>
> <documentnumber>12345</documentnumber>
> <invoicebalance>99.99</invoicebalance>
> <invoicenumber>INV123</invoicenumber>
> <invoicetrantype>FS</invoicetrantype>
> </InvoiceBalanceData>
> <InvoiceBalanceData>
> <documentnumber>444</documentnumber>
> <invoicebalance>88.88</invoicebalance>
> <invoicenumber>INV345</invoicenumber>
> <invoicetrantype>AB</invoicetrantype>
> </InvoiceBalanceData>
> </InvoiceBalanceData>
> Can someone help me with my annotated XSD file? tia.
I should add that after I attempt to import the XML, the script
finishes successfully (this is from a DTS package), but no rows are
imported into the table.|||I would process it as attribute centric
declare @.xml xml
SET @.xml =
'<root>
<InvoiceBalanceData documentnumber="12345" invoicebalance="99.99"
invoicenumber="INV123" invoicetrantype="FS" />
<InvoiceBalanceData documentnumber="444" invoicebalance="88.88"
invoicenumber="INV345" invoicetrantype="AB" />
</root>'
select @.xml
SELECT
[inv].[ref].value('@.documentnumber', 'int'),
[inv].[ref].value('@.invoicebalance', 'money')
FROM @.xml.nodes('/root/InvoiceBalanceData') [inv]([ref])
See SQL Server BOL as well.
-- Create tables for later population using OPENXML.
CREATE TABLE Customers (CustomerID varchar(20) primary key,
ContactName varchar(20),
CompanyName varchar(20))
GO
CREATE TABLE Orders( CustomerID varchar(20), OrderDate datetime)
GO
DECLARE @.docHandle int
DECLARE @.xmlDocument nvarchar(max) -- or xml type
SET @.xmlDocument = N'<ROOT>
<Customers CustomerID="XYZAA" ContactName="Joe" CompanyName="Company1">
<Orders CustomerID="XYZAA" OrderDate="2000-08-25T00:00:00"/>
<Orders CustomerID="XYZAA" OrderDate="2000-10-03T00:00:00"/>
</Customers>
<Customers CustomerID="XYZBB" ContactName="Steve"
CompanyName="Company2">No Orders yet!
</Customers>
</ROOT>'
EXEC sp_xml_preparedocument @.docHandle OUTPUT, @.xmlDocument
-- Use OPENXML to provide rowset consisting of customer data.
INSERT Customers
SELECT *
FROM OPENXML(@.docHandle, N'/ROOT/Customers')
WITH Customers
-- Use OPENXML to provide rowset consisting of order data.
INSERT Orders
SELECT *
FROM OPENXML(@.docHandle, N'//Orders')
WITH Orders
-- Using OPENXML in a SELECT statement.
SELECT * FROM OPENXML(@.docHandle, N'/ROOT/Customers/Orders') WITH
(CustomerID nchar(5) '../@.CustomerID', OrderDate datetime)
-- Remove the internal representation of the XML document.
EXEC sp_xml_removedocument @.docHandle
"Larry Bud" <larrybud2002@.yahoo.com> wrote in message
news:6ebab460-5eda-4c48-a4be-1ef478130ea3@.i29g2000prf.googlegroups.com...
> On Dec 13, 10:31 am, Larry Bud <larrybud2...@.yahoo.com> wrote:
> I should add that after I attempt to import the XML, the script
> finishes successfully (this is from a DTS package), but no rows are
> imported into the table.

Wednesday, March 28, 2012

Help with sql 2005 integration services.

Hi,
I want to be able to do a simple import from an excel spreadsheet i.e.
DTS, within SQL Server Management Studio. I have added two registered
servers, but I cannot register them to the integration services, so
that I can then do an import. is this correct or am I doing somethign
wrong? I have used SQL Server Business Intelligence Development
Studio, but surely there is a way to do it simply withing SSMS.
Appreciate any help on this.
Damon.You can do it pretty much the same way as with SQL 2000. Try right clicking
on the database name in SSMS, select Tasks, Import Data and go from there...
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
> Hi,
> I want to be able to do a simple import from an excel spreadsheet i.e.
> DTS, within SQL Server Management Studio. I have added two registered
> servers, but I cannot register them to the integration services, so
> that I can then do an import. is this correct or am I doing somethign
> wrong? I have used SQL Server Business Intelligence Development
> Studio, but surely there is a way to do it simply withing SSMS.
> Appreciate any help on this.
> Damon.
>|||There are a number of different ways to start the SSIS Import / Export
wizard. You can start it a couple of ways using the SQL Server Business
Intelligence Development Studio. Or you can start
it using the SQL Server Management Studio. Lastly, you can start it using an
executable.
Take a look into the below URL on using Improt/Export wizard in SQL 2005:-
http://www.databasejournal.com/feat...cle.php/3580216
Thanks
Hari
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
> Hi,
> I want to be able to do a simple import from an excel spreadsheet i.e.
> DTS, within SQL Server Management Studio. I have added two registered
> servers, but I cannot register them to the integration services, so
> that I can then do an import. is this correct or am I doing somethign
> wrong? I have used SQL Server Business Intelligence Development
> Studio, but surely there is a way to do it simply withing SSMS.
> Appreciate any help on this.
> Damon.
>|||On 14 Feb, 13:11, "Hari Prasad" <hari_prasa...@.hotmail.com> wrote:[vbcol=seagreen]
> There are a number of different ways to start the SSIS Import / Export
> wizard. You can start it a couple of ways using the SQL Server Business
> Intelligence Development Studio. Or you can start
> it using the SQL Server Management Studio. Lastly, you can start it using
an
> executable.
> Take a look into the below URL on using Improt/Export wizard in SQL 2005:-
> http://www.databasejournal.com/feat...cle.php/3580216
> Thanks
> Hari
> "nomad" <d.bedg...@.ntlworld.com> wrote in message
> news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
>
>
>
>
Excellent, thanks very much. Fair play though, I should have checked
there.
Thanks again.
Damon

Help with sql 2005 integration services.

Hi,
I want to be able to do a simple import from an excel spreadsheet i.e.
DTS, within SQL Server Management Studio. I have added two registered
servers, but I cannot register them to the integration services, so
that I can then do an import. is this correct or am I doing somethign
wrong? I have used SQL Server Business Intelligence Development
Studio, but surely there is a way to do it simply withing SSMS.
Appreciate any help on this.
Damon.You can do it pretty much the same way as with SQL 2000. Try right clicking
on the database name in SSMS, select Tasks, Import Data and go from there...
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
> Hi,
> I want to be able to do a simple import from an excel spreadsheet i.e.
> DTS, within SQL Server Management Studio. I have added two registered
> servers, but I cannot register them to the integration services, so
> that I can then do an import. is this correct or am I doing somethign
> wrong? I have used SQL Server Business Intelligence Development
> Studio, but surely there is a way to do it simply withing SSMS.
> Appreciate any help on this.
> Damon.
>|||There are a number of different ways to start the SSIS Import / Export
wizard. You can start it a couple of ways using the SQL Server Business
Intelligence Development Studio. Or you can start
it using the SQL Server Management Studio. Lastly, you can start it using an
executable.
Take a look into the below URL on using Improt/Export wizard in SQL 2005:-
http://www.databasejournal.com/features/mssql/article.php/3580216
Thanks
Hari
"nomad" <d.bedgood@.ntlworld.com> wrote in message
news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
> Hi,
> I want to be able to do a simple import from an excel spreadsheet i.e.
> DTS, within SQL Server Management Studio. I have added two registered
> servers, but I cannot register them to the integration services, so
> that I can then do an import. is this correct or am I doing somethign
> wrong? I have used SQL Server Business Intelligence Development
> Studio, but surely there is a way to do it simply withing SSMS.
> Appreciate any help on this.
> Damon.
>|||On 14 Feb, 13:11, "Hari Prasad" <hari_prasa...@.hotmail.com> wrote:
> There are a number of different ways to start the SSIS Import / Export
> wizard. You can start it a couple of ways using the SQL Server Business
> Intelligence Development Studio. Or you can start
> it using the SQL Server Management Studio. Lastly, you can start it using an
> executable.
> Take a look into the below URL on using Improt/Export wizard in SQL 2005:-
> http://www.databasejournal.com/features/mssql/article.php/3580216
> Thanks
> Hari
> "nomad" <d.bedg...@.ntlworld.com> wrote in message
> news:1171456545.592838.73050@.a75g2000cwd.googlegroups.com...
> > Hi,
> > I want to be able to do a simple import from an excel spreadsheet i.e.
> > DTS, within SQL Server Management Studio. I have added two registered
> > servers, but I cannot register them to the integration services, so
> > that I can then do an import. is this correct or am I doing somethign
> > wrong? I have used SQL Server Business Intelligence Development
> > Studio, but surely there is a way to do it simply withing SSMS.
> > Appreciate any help on this.
> > Damon.
Excellent, thanks very much. Fair play though, I should have checked
there.
Thanks again.
Damon

Sunday, February 19, 2012

Help with Insert/Trigger

Just curious if there's anything in SQL comparable to a FOR EACH ROW trigger in Oracle.
I'm doing an import of a bunch of rows into a parent table using an INSERT/SELECT statement and I have triggers that fire pulling data from the same row in the source table into the child tables and creating the foreign key references. The problem lies in
the fact that the triggers only fire once seeing as how it reads the INSERT statement as one statement and not row by row.
Any thoughts?
Thanks.
Pete
There is no equivalent. You can search the newsgroups (.programming) for
many examples. In general, set-based solutions are faster and more
efficient for any sql programming.
"Pete" <Pete@.discussions.microsoft.com> wrote in message
news:3287C30A-AAF3-408C-83F9-9F72DC78ADAD@.microsoft.com...
> Just curious if there's anything in SQL comparable to a FOR EACH ROW
trigger in Oracle.
> I'm doing an import of a bunch of rows into a parent table using an
INSERT/SELECT statement and I have triggers that fire pulling data from the
same row in the source table into the child tables and creating the foreign
key references. The problem lies in the fact that the triggers only fire
once seeing as how it reads the INSERT statement as one statement and not
row by row.
> Any thoughts?
> Thanks.
> Pete