Showing posts with label greetings. Show all posts
Showing posts with label greetings. Show all posts

Monday, March 19, 2012

Importing Excel 2007 and/ or DBF files into SQl server 2005

Greetings,

I'm having a tough time importing some of my legacy database into sql.
I have a number of dbase (IV) files I need to get into SQL. I have tried building a SSIS package with either an foxpro oledb connection or a jet 4.0 one, none of them work bec. of inconsistencies in the data format in my tables (e.g. date fields, etc).

I have tried to save the .dbfs as excel 2007 files, taking advantage of the larger space that comes with '07. Problem is you can't use the import/export wizard with 2007 for some reason and I haven't been able to create a package with the access 12 oledb as I have read.

I have to get some crucial data out of that old system and into the new one and I can't seem to be able to import them properly.

Any hints on what I should do ? (maybe I'm doing something awfully wrong)

Thank you for taking the time to answer my question,
Val

If you have SP2 installed, you should be able to load data from Excel 2007 format using the I/E wizard. Do not use the Excel connection, but use the new OLE DB provider for Office 2007. You will need to set extended properties to "Excel 12.0".

Let me know if you need more assistance.

Thanks.

|||

Try by looking at this : http://msdn2.microsoft.com/en-us/library/aa337084.aspx and also you'll need to configure your connection manually to connect. Set up a Jet OLEDB Connection - point to your folder containing the DBase files. Click the "All" button and change the "Extended Properties" to "DBASE IV".

Sunday, February 19, 2012

Importing a XML doc into relational tables.

HELP! This is driving me mad...
Greetings all.
I am trying to import XML into SQL.
I have the following ingredients:
1 X xml document with 2 levels. Parent > child
1 X xml source object
2 X tables in SQL.
The XML doc is quite simple. Parent element (PLU) and a child element
(DESC)
The SQL tables are PLU (PLU_Code) and PLU_Child (PLU_Code, DESC)
(PLU_Code is a FK.
When setting up the xml, it gives me two outputs (Auto created the xsd)
PLU and DESC.
PLU has PLU_Code and PLU_Id
DESC as PLU_Id and DESC.
As per MS, the _Id field is used to retain the relationship. Fine.
I can populate the main table (PLU) fine. I cannot populate the child
table because of the FK.
If MS provides the PLU_Id, how do I use it?
I do not want to use a lookup (Can't because on the child I do not
have a PLU_Code field).
Any guidance?
Cheers,
CrispinYou have to use the @.mp:id and @.mp:parentid meta-properties to JOIN the
results and get the Parent Key. The problem is you have to use temp tables
due to technological limitations. So it gives something like this:
SELECT * into #ParentTable
FROM OPENXML(@.hDOC, 'ParentNode', flag)
WITH (ParentKey, xmlID int '@.mp:id')
SELECT * into #ChildTable
FROM OPENXML(@.hDOC, 'ChildNode', flag)
WITH (someChildFields ..., xmlParentID int '@.mp:parentid')
Then JOIN the temp tables and INSERT:
INSERT INTO childTable (ParentKey, someChildFields)
SELECT ParentKey, someChildFields
FROM #ParentTable T1 INNER JOIN #ChildTable T2 ON
(T1.xmlID = T2.xmlParentID)
Have fun
"crispin.proctor@.gmail.com" wrote:

> HELP! This is driving me mad...
>
> Greetings all.
>
> I am trying to import XML into SQL.
> I have the following ingredients:
> 1 X xml document with 2 levels. Parent > child
> 1 X xml source object
> 2 X tables in SQL.
>
> The XML doc is quite simple. Parent element (PLU) and a child element
> (DESC)
> The SQL tables are PLU (PLU_Code) and PLU_Child (PLU_Code, DESC)
> (PLU_Code is a FK.
>
> When setting up the xml, it gives me two outputs (Auto created the xsd)
> PLU and DESC.
> PLU has PLU_Code and PLU_Id
> DESC as PLU_Id and DESC.
>
> As per MS, the _Id field is used to retain the relationship. Fine.
>
> I can populate the main table (PLU) fine. I cannot populate the child
> table because of the FK.
>
> If MS provides the PLU_Id, how do I use it?
>
> I do not want to use a lookup (Can't because on the child I do not
> have a PLU_Code field).
>
> Any guidance?
>
> Cheers,
> Crispin
>|||Fleo,
This is the way I could get around it but this method detracts from the
new SSIS pipeline method and would be rather slow.
I could have very large documents which I now have to do the following:
1) Load each level into temp tables.
2) Join the temp tables together using the ID's created.
3) Load them into their final resting place. (This cannot be done in
step two as the keys are not unique)
Within that process, I have to do many lookups etc and find all this
would be rather slow.
Could they not be loaded into datasets and manipulated from there on?
I am busy with that but keep getting an error saying "You cannot add an
output column to the output collection" ('?)
Cheers,
Crispin|||Hi,
Sorry I have no idea, I am fairly new to this. I am trying to do about the
same thing.
Anyone with ideas? Would .xsd schema with annotations help here?
"crispin.proctor@.gmail.com" wrote:

> Fleo,
> This is the way I could get around it but this method detracts from the
> new SSIS pipeline method and would be rather slow.
> I could have very large documents which I now have to do the following:
> 1) Load each level into temp tables.
> 2) Join the temp tables together using the ID's created.
> 3) Load them into their final resting place. (This cannot be done in
> step two as the keys are not unique)
> Within that process, I have to do many lookups etc and find all this
> would be rather slow.
> Could they not be loaded into datasets and manipulated from there on?
> I am busy with that but keep getting an error saying "You cannot add an
> output column to the output collection" ('?)
>
> Cheers,
> Crispin
>