Import/Export files (.txt/.csv/.xls) into SQL 2005 Compact Edition

  • I have an SDF file. I need to import some new data into a new table in that SDF. The data could be a .TXT/.csv/.xls.. What are the ways available to do the import/export into SQL 2005 CE?

    Also, how to query an table in SDF from an SQL 2005 Enterprise edition?

  • Pardon my ignorance. What's an "SDF"?

    --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)

  • Jeff,

    yes, it was an revelation to me. I didnt knew abt this.

    From MSDN:

    "A SQL Server Compact Edition database is stored in a file with the .sdf extension"

    http://msdn.microsoft.com/en-us/library/ms171986(v=SQL.90).aspx

  • Jeff Moden (4/23/2011)


    Pardon my ignorance. What's an "SDF"?

    SQL Server Compact Edition databases are supposed to a good idea for mobile phones and other portable devices;There's no service like SQLServer needed to run against them, it's kind of like an access database in that regard.

    I think the target audience is actually Laptops that need to sync with a master database on an intermittent basis, because you can make push/pull replication subscriptions to them. You know, the typical, in the field issues where they need access to database stuff, add invoices, and sync later.

    At least for smaller devices/ mobile development, The problem is that it requires the compact .NET framework, which in turn requires the Windows mobile operating system.

    Since that's not as popular as say, the Android OS, your future markets a little more limited; I ended up using SQLite database instead, as there's more code examples for using that, and can be used with or without the Windows OS on those portables, as well as in full windows Operating systems.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Jeff Moden (4/23/2011)


    Pardon my ignorance. What's an "SDF"?

    Crikey Jeff, I'm agog with amazement :hehe:

    You being a SQL god an 'all 🙂

    I guess DBA's don't venture out of the sandbox after all 😛

    Far away is close at hand in the images of elsewhere.
    Anon.

  • David Burrows (4/24/2011)


    Jeff Moden (4/23/2011)


    Pardon my ignorance. What's an "SDF"?

    Crikey Jeff, I'm agog with amazement :hehe:

    You being a SQL god an 'all 🙂

    I guess DBA's don't venture out of the sandbox after all 😛

    BWAA-HAAA!!!! I don't consider CE to be SQL in any way, shape, or form. In fact, I'm sure the abbreviation of "CE" actually stands for "Crippled Edition" or "Cruddy Example" or "Crap/Excrement". It's nothing more than a data dumping ground for the very things people have mentioned. It can't use stored procedures, functions, views, or even variables. The best it can do is be interfaced with a front end using 100% embedded code. Sure, it'll run some pretty limited SQL scripts. After I found out what it was for, I never looked at it again. Certainly not long enough to be made familiar with the file extensions it uses. 😛

    My closest contact with CE was when my boss asked me to convert some rather sophisticated T-SQL to CE. After studying about its limitations, I told my boss that he really needs to hire a good front end developer that can read T-SQL well enough to write objects and procs in the "C" family of code from it because there was simply no way possible to migrate T-SQL to CE.

    Does CE do what it was designed to do? Absolutely. And that's precisely why I don't use it nor do I study it. 🙂 It's apparently MicroSoft's answer to about the closest you can get to a NO SQL product without actually being one.

    --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)

  • Ok... I got all of my griping out of the way :-D. Does anyone have an answer for balasach82 question about how to import txt/csv/xls data into CE because I sure don't know. I'm thinking the front end code would need to do that.

    --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)

  • Nice riposte Jeff 🙂

    I consider myself remonstrated :crying:

    My only dabble with SDF was on a scanner with an older version of CE to SQL2K via Web Service. I believe the newer versions allow better access to SQL Server but I could be wrong. I will check with one of my colleagues who has worked on this sort of thing when I get back to the shop tomorrow.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Gah!... I didn't mean to turn it into a rant. Sorry. The only real advantage that CE has compared to custom code might be it's ability to sort and join so you don't have to write that stuff into a custom file handler.

    --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)

  • You can connect to a CE database using the Server Management Studio (choose CE from the Server Type dropdown) and then you will have to browse to the directory containing the sdf file. I believe you can import/export data from there.

    A program could also be written to do imports and exports.

    John

  • You can use SSIS, there is a data destination type of SQL Compact.

Viewing 11 posts - 1 through 10 (of 10 total)

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