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