Reading Ad Hoc Text Files with OpenDataSource

  • Comments posted to this topic are about the item Reading Ad Hoc Text Files with OpenDataSource

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Good, short, sweet coverage of OpenDataSource and some of the key advantages to using it and when to use it... Nicely done!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi,

    Have you found a way to do this in SQL 2005 64bit?

    Apparently there is a MSDASQL provider being released in Longhorn for 64bit , but I haven't been able to find any other information.

    Your help will be much appreciated!

    Regards,

    GG

  • GG (12/13/2007)


    Hi,

    Have you found a way to do this in SQL 2005 64bit?

    Apparently there is a MSDASQL provider being released in Longhorn for 64bit , but I haven't been able to find any other information.

    Your help will be much appreciated!

    Regards,

    GG

    I have been searching for that ever since my company got a 64bit server, last week. My current ugly work around is to use linked servers to execute the procedures on a 32 bit server and then bring the results across to the 64 bit server.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • My current ugly work around is to use linked servers to execute the procedures on a 32 bit server and then bring the results across to the 64 bit server.

    Same for me, No JET support in 64 bits.

    About SQL2008? is it going to work in either 32 or 64 bits?

    BI Guy

  • It definitely helps me to understand about OpenDataSource. I'm working on a project to see how to create sample SQL databases (32bit/64bit SQL Server 2005/2008 including Express Edition) for a .NET application. I'm trying to figure out the following items:

    1. How to create the databases?

    e.g.

    - using sql scripts

    - backup/restore

    - detach/attach

    2. Where to store the sample data?

    e.g.

    - xml

    - mdb

    - text files

    - csv

    - backup

    - detached files

    3. How to import the data?

    e.g.

    BCP

    BULK INSERT

    Import/Export Wizard

    SSIS

    OPENROWSET

    OPENDATASOURCE

    OPENQUERY

    SqlBulkCopy

    Backup/Restore

    Detach/Attach

    What are the pros and cons (especially what datatype cannot be imported) in each option? What data source should I create (e.g. text file, XML, Access database(MDB), Excel file (CVS)) if portability is a must? Ideally, the data importing can be initialized from a .NET 3.0/3.5 application instead of thru SSMS or command prompt.

  • pcwc66 (12/13/2007)


    It definitely helps me to understand about OpenDataSource. I'm working on a project to see how to create sample SQL databases (32bit/64bit SQL Server 2005/2008 including Express Edition) for a .NET application. I'm trying to figure out the following items:

    1. How to create the databases?

    2. Where to store the sample data?

    3. How to import the data?

    What are the pros and cons (especially what datatype cannot be imported) in each option? What data source should I create (e.g. text file, XML, Access database(MDB), Excel file (CVS)) if portability is a must? Ideally, the data importing can be initialized from a .NET 3.0/3.5 application instead of thru SSMS or command prompt.

    Most of those questions revolve around exactly what you are trying to do, but for a few rules of thumb:

    1.

    If you are moving a preexisting database to a test environment I would use backup and restore. It tends to be one of the easier ways and more complete ways. If you are creating something new or highly modified, I would use t-sql scripts as they will give you the most direct control.

    2. How you export the data depends on who you are sending it to and what they can read. As a general rule of thumb, csv files are simultaneously the smallest way to store the data and one of the most widely accepted since they can be easily read by a variety of programs including straight text editors and they can be imported into almost anything. The downside of course is that they do not include within them information like data type or relations between groupings of files that can be more thoroughly expressed in a richer format. For a richer format, you may wish to use access files or create a sql backup and send the entire backup file, depending again on your exact intent.

    3. When it works, bulk insert is almost always one of the fastest and most efficient ways of importing, but it only works on certain file types formatted in certain ways and it has very little fault tolerance. Also for rarely repeated imports, there is nothing wrong with just using the SSIS or DTS wizards. I tend to use opendatasource for a lot of the automated imports in procedures because it provides more flexibility and more fault tolerance than bulk insert while remaining pure T-SQL and not requiring outside programs.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • Tim,

    Thanks for prompt reply on my questions. Besides reading your article, I have been reading other articles regarding importing data to SQL Server. This article about SqlBulkCopy http://www.developer.com/net/asp/article.php/10917_3702826_1 is another good information and may applicable to my case since I'm dealing with .net application.

  • PCWC66, thanks for pointing out that article. It is one of the best best primers on SqlBulkCopy that I have seen. It is definitely a great technique for the right circumstances, but there are times when it is desirable to keep things T-SQL pure or nearly so.

    ---
    Timothy A Wiseman
    SQL Blog: http://timothyawiseman.wordpress.com/

  • I'm in SQL 2008 64bit clustered this is my unhappiness

    Error/Information message I receive

    The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered.

    Query I'm running

    SELECT * FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',

    'Data Source=C:\SqlServerInstances.xls;Extended Properties=Excel 8.0')...[Customers$]

    Am I missing something? Have they renamed the provider to something else, or simply removed it .

    End of day so tired come back with a fresh brain tomorrow in the mean time if you got something please share!

  • I am having the same issue using MSADASQL for Text driver on SQL2008 64 Bit Machine.

    Works fine on SQL2008 32 Bit machine.

    Mick

  • My workaround is to run through a SQL Agent job with the SSIS step Execution Option set to use 32 bit runtime.

    BI Guy

  • Did you ever get a fix for this? When attempting to do a similar thing I get the exact same error (on a 32-bit system)

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply