Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. sql server table records to sqlite

sql server table records to sqlite

Scheduled Pinned Locked Moved Database
databasequestionsharepointandroidsql-server
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jojoba2011

    thanks for Solution, but i wanna something like this cause the speed is very hight and wont take time :

    SELECT tt.IdAmlak, tt.ParentId, tt.NameOpp, tt.Price, tt.[Square],
    tt.OstanShahrMantagha, tt.PhoneAddress, tt.CountAmount
    INTO TestTable
    FROM tblTesting tt

    tblTesting : Table in database Sql Server 2008 in server internet TestTable : Table in Database SQLite in local (android mobile)

    _ Offline
    _ Offline
    _Damian S_
    wrote on last edited by
    #5

    Well, if you can have an ODBC connection to the server on the web, and one to the android device, there's no reason why you couldn't do something like that. I'm not convinced it would be quicker than simply downloading the csv file and processing it locally in one go...

    Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

    J 1 Reply Last reply
    0
    • M Mycroft Holmes

      Is this a once off operation or do you need to repeat it. One time, use the CSV method. If it must be repeatable then you need to set up a service (WCF) between the databases, you should not connect an online database directly to a remote database.

      Never underestimate the power of human stupidity RAH

      J Offline
      J Offline
      jojoba2011
      wrote on last edited by
      #6

      thanks for solution I need to connect and get all info every 2 days. cause the data of that table change every 2 days.

      M 1 Reply Last reply
      0
      • _ _Damian S_

        Well, if you can have an ODBC connection to the server on the web, and one to the android device, there's no reason why you couldn't do something like that. I'm not convinced it would be quicker than simply downloading the csv file and processing it locally in one go...

        Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

        J Offline
        J Offline
        jojoba2011
        wrote on last edited by
        #7

        thanks for solution can u give me a sample for

        csv file and processing it locally

        and i can do this also ,so plz give sample :

        if you can have an ODBC connection to the server on the web, and one to the android device

        _ 1 Reply Last reply
        0
        • J jojoba2011

          thanks for solution can u give me a sample for

          csv file and processing it locally

          and i can do this also ,so plz give sample :

          if you can have an ODBC connection to the server on the web, and one to the android device

          _ Offline
          _ Offline
          _Damian S_
          wrote on last edited by
          #8

          To create a csv file, simply run a query on your sql server and save the results to a file. For the ODBC connection, create a couple of DSN's locally (one to the sql server, one to sqlite), then from a common location connect to both and run your query. This might be possible through a local SQL Server Management Studio copy, or through anything else that allows you to attach ODBC databases, even MS Access... Warning - MS Access will be very, very slow.

          Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

          J 1 Reply Last reply
          0
          • _ _Damian S_

            To create a csv file, simply run a query on your sql server and save the results to a file. For the ODBC connection, create a couple of DSN's locally (one to the sql server, one to sqlite), then from a common location connect to both and run your query. This might be possible through a local SQL Server Management Studio copy, or through anything else that allows you to attach ODBC databases, even MS Access... Warning - MS Access will be very, very slow.

            Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

            J Offline
            J Offline
            jojoba2011
            wrote on last edited by
            #9

            i have googled what about this sp :

            insert into CRM-CMS.dbo.tableName
            select * from [217.66.216.77,1633].CRM-CMS.dbo.tblTesting

            _ 1 Reply Last reply
            0
            • J jojoba2011

              i have googled what about this sp :

              insert into CRM-CMS.dbo.tableName
              select * from [217.66.216.77,1633].CRM-CMS.dbo.tblTesting

              _ Offline
              _ Offline
              _Damian S_
              wrote on last edited by
              #10

              Try just running the select portion of it and see if you return results. Your insert will need to use a field list though, not *. eg: insert into table1 (field1, field2) select field1, field2 from table2 Also, you would need to clear the data from your local table first if you are wanting to replace it with the data from your server.

              Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

              J 1 Reply Last reply
              0
              • J jojoba2011

                thanks for solution I need to connect and get all info every 2 days. cause the data of that table change every 2 days.

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #11

                Then you need to build a service between the databases, we use WCF.

                Never underestimate the power of human stupidity RAH

                J 1 Reply Last reply
                0
                • M Mycroft Holmes

                  Then you need to build a service between the databases, we use WCF.

                  Never underestimate the power of human stupidity RAH

                  J Offline
                  J Offline
                  jojoba2011
                  wrote on last edited by
                  #12

                  can please give small sample?

                  M 1 Reply Last reply
                  0
                  • J jojoba2011

                    can please give small sample?

                    M Offline
                    M Offline
                    Mycroft Holmes
                    wrote on last edited by
                    #13

                    There are plenty available with a quick search here articles[^] and google[^]

                    Never underestimate the power of human stupidity RAH

                    J 1 Reply Last reply
                    0
                    • _ _Damian S_

                      Try just running the select portion of it and see if you return results. Your insert will need to use a field list though, not *. eg: insert into table1 (field1, field2) select field1, field2 from table2 Also, you would need to clear the data from your local table first if you are wanting to replace it with the data from your server.

                      Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!

                      J Offline
                      J Offline
                      jojoba2011
                      wrote on last edited by
                      #14

                      i got this code : but cannot run for SQLite : i get this error in sqlite : SQLite error near "INTO" : syntax error

                      cmd.CommandText = @"SELECT top(5) IdAmlak, ParentId, NameOpp, Price, [Square],
                      OstanShahrMantagha, PhoneAddress, CountAmount
                      INTO Melk
                      FROM OPENDATASOURCE(
                      'SQLOLEDB',
                      'Data Source=217.66.216.77,1633;User ID=tinadbuser;Password=dbtin123ir'
                      ).[CRM-CMS].dbo.tblTesting";

                      L 1 Reply Last reply
                      0
                      • M Mycroft Holmes

                        There are plenty available with a quick search here articles[^] and google[^]

                        Never underestimate the power of human stupidity RAH

                        J Offline
                        J Offline
                        jojoba2011
                        wrote on last edited by
                        #15

                        i got this code :
                        but cannot run for SQLite :

                        i get this error in sqlite :

                        <code>SQLite error near "INTO" : syntax error </code>

                        <pre lang="sql">cmd.CommandText = @"SELECT top(5) IdAmlak, ParentId, NameOpp, Price, [Square],
                        OstanShahrMantagha, PhoneAddress, CountAmount
                        INTO Melk
                        FROM OPENDATASOURCE(
                        'SQLOLEDB',
                        'Data Source=217.66.216.77,1633;User ID=tinadbuser;Password=dbtin123ir'
                        ).[CRM-CMS].dbo.tblTesting";</pre>

                        M 1 Reply Last reply
                        0
                        • J jojoba2011

                          i got this code : but cannot run for SQLite : i get this error in sqlite : SQLite error near "INTO" : syntax error

                          cmd.CommandText = @"SELECT top(5) IdAmlak, ParentId, NameOpp, Price, [Square],
                          OstanShahrMantagha, PhoneAddress, CountAmount
                          INTO Melk
                          FROM OPENDATASOURCE(
                          'SQLOLEDB',
                          'Data Source=217.66.216.77,1633;User ID=tinadbuser;Password=dbtin123ir'
                          ).[CRM-CMS].dbo.tblTesting";

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #16

                          You don't want to do this using a linked server; cleanest way is to generate the CSV (there's documentation on the internet); to send the CSV, and to bulkload it. SQLite does not use TSQL. If you use multiple database-systems from different vendors, it'd be preferable to keep your SQL in the SQL92-dialect.

                          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                          J 1 Reply Last reply
                          0
                          • J jojoba2011

                            i got this code :
                            but cannot run for SQLite :

                            i get this error in sqlite :

                            <code>SQLite error near "INTO" : syntax error </code>

                            <pre lang="sql">cmd.CommandText = @"SELECT top(5) IdAmlak, ParentId, NameOpp, Price, [Square],
                            OstanShahrMantagha, PhoneAddress, CountAmount
                            INTO Melk
                            FROM OPENDATASOURCE(
                            'SQLOLEDB',
                            'Data Source=217.66.216.77,1633;User ID=tinadbuser;Password=dbtin123ir'
                            ).[CRM-CMS].dbo.tblTesting";</pre>

                            M Offline
                            M Offline
                            Mycroft Holmes
                            wrote on last edited by
                            #17

                            At a guess I would say SQL Lite does not support INTO so make the query like a normal insert statement.

                            Insert Melk (field, names, list) Select ...

                            Never underestimate the power of human stupidity RAH

                            1 Reply Last reply
                            0
                            • L Lost User

                              You don't want to do this using a linked server; cleanest way is to generate the CSV (there's documentation on the internet); to send the CSV, and to bulkload it. SQLite does not use TSQL. If you use multiple database-systems from different vendors, it'd be preferable to keep your SQL in the SQL92-dialect.

                              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

                              J Offline
                              J Offline
                              jojoba2011
                              wrote on last edited by
                              #18

                              Realy thanks! I have installed an app android that do same as what i wanna and i have installed it and got this file that have info but cannot read that. what type of data it have .is it SQLite or something else. how can i do that same? download the data file : http://upload.ugm.ac.id/221asnaf and download app : http://upload.ugm.ac.id/561A0829-MashaghelHamrah.apk[^] thanks in advanced !

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups