{"id":21119,"date":"2022-11-23T12:24:46","date_gmt":"2022-11-23T10:24:46","guid":{"rendered":"https:\/\/www.wjst.de\/blog\/?p=21119"},"modified":"2022-11-23T16:06:48","modified_gmt":"2022-11-23T14:06:48","slug":"convert-ms-sql-server-database-to-sqlite","status":"publish","type":"post","link":"https:\/\/www.wjst.de\/blog\/sciencesurf\/2022\/11\/convert-ms-sql-server-database-to-sqlite\/","title":{"rendered":"Convert MS SQL Server database to SQLITE"},"content":{"rendered":"<p>It took me basically 2 days to figure that out as most hits at Google were misleading.<br \/>\nMy recommendation now is to install Docker and use a 2019 version of MS SQL Server.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\ndocker pull mcr.microsoft.com\/mssql\/server:2019-latest\r\ndocker run -e &quot;ACCEPT_EULA=Y&quot; -e &quot;MSSQL_SA_PASSWORD=you_should_know_it&quot; -e &quot;MSSQL_PID=Express&quot; -p 1433:1433 --name sql1 --hostname sql1 -d mcr.microsoft.com\/mssql\/server:2019-latest\r\nsudo docker ps -a\r\n# gives you the id like bea83... below that is needed to copy the mdf file to the container\r\ndocker cp \/Users\/you_should_know\/database.mdf bea8369066ed:\/var\/opt\/mssql\/data\r\ndocker cp \/Users\/you_should_know\/database_log.ldf bea8369066ed:\/var\/opt\/mssql\/data\r\n<\/pre>\n<p>Login as su and change permission of the uploaded file. Afterwards attach the database<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nsudo docker exec -u 0 -it sql1 &quot;bash&quot;\r\nchmod 777 \/var\/opt\/mssql\/data\/data*.*\r\n\/opt\/mssql-tools\/bin\/sqlcmd -S localhost -U sa -P &quot;you_should_know_it&quot; -Q &quot;CREATE DATABASE &#x5B;new_data_base] ON (FILENAME = N'\/var\/opt\/mssql\/data\/database.mdf'),(FILENAME = N'\/var\/opt\/mssql\/data\/database_log.ldf') FOR ATTACH&quot;\r\n<\/pre>\n<p>Cool, on localhost:1443 we can now see MS SQL Server working..<br \/>\nConnecting with Azure was a dead end, also with SQL Pro Studio as the export could not be read by SQLITE.<br \/>\n<a href=\"https:\/\/razorsql.com\/index.html\">Razor SQL<\/a> worked (do not use DB Tools -> Export but DB Tools -> Database Conversion).<br \/>\nThis generates a sql file that SQLITE will understand.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n cat run.sql | sqlite3 database.db\r\n<\/pre>\n\n<p>&nbsp;<\/p>\n<div class=\"bottom-note\">\n  <span class=\"mod1\">CC-BY-NC Science Surf , accessed 26.04.2026<\/span>\n <\/div>","protected":false},"excerpt":{"rendered":"<p>It took me basically 2 days to figure that out as most hits at Google were misleading. My recommendation now is to install Docker and use a 2019 version of MS SQL Server. docker pull mcr.microsoft.com\/mssql\/server:2019-latest docker run -e &quot;ACCEPT_EULA=Y&quot; -e &quot;MSSQL_SA_PASSWORD=you_should_know_it&quot; -e &quot;MSSQL_PID=Express&quot; -p 1433:1433 &#8211;name sql1 &#8211;hostname sql1 -d mcr.microsoft.com\/mssql\/server:2019-latest sudo docker ps &hellip; <a href=\"https:\/\/www.wjst.de\/blog\/sciencesurf\/2022\/11\/convert-ms-sql-server-database-to-sqlite\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Convert MS SQL Server database to SQLITE<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2025,2980],"class_list":["post-21119","post","type-post","status-publish","format-standard","hentry","category-computer-software","tag-conversion","tag-database"],"_links":{"self":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/21119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/comments?post=21119"}],"version-history":[{"count":7,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/21119\/revisions"}],"predecessor-version":[{"id":21127,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/posts\/21119\/revisions\/21127"}],"wp:attachment":[{"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/media?parent=21119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/categories?post=21119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjst.de\/blog\/wp-json\/wp\/v2\/tags?post=21119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}