Monday, March 19, 2012

BULK INSERT maybe ??

I have a directory with files:

X.dbf
X.mdx
Y.dbf
Y.mdx
...

These files contain updates for my DB (I don't know their structure). How I can insert them in temporary tables on the SQL server ?

Note: I don't want to use Import/Export Tool, cause I will need this insert as scripts...I'd use DTS.

-PatP|||I'd use DTS.

-PatP

You would?

I'd create a sproc...

USing xp-Cmdshell, I would interogate the directory and load the file names to a table.

I would process the files 1 by 1

I would the bcp the data in to a single column varchar table

I would then process the data.

Bu if you don't know the structure of the data, what would you propose you'd do?|||Last time I did something like this, the .dbf extension files came from dBase V. DTS has an interface for that datafile type. As for .mdx ... ?|||It isn't hard to determine the schema of a DBF file, as Tom pointed out they are just dBase files which are effectively a single table with the schema tucked into the file header. You can relatively easily import arbitrary dbf files into a database from within a DTS package... It is more complex than dealing with a static structure, but not rocket science by any means.

The MDX files are just queries written as Multi-dimensional Expressions. Those can simply be stuffed into a TEXT column somewhere, probably the best organization would be to simply track what file they came from (X.MDX) and the text in a single table, maybe with some decorative columns to track when the file was timestamped, when it was imported into the table, etc.

-PatP|||Multi-dimensional Expressions? I may be way off, but I think I remember MDX to be primary indexes and NDX secondary (?)...Or maybe it's FoxPro? It's been awhile.|||I should just make it part of my sig...

"It really helps if you read these things"|||...and your point is...?

No comments:

Post a Comment