Proper way to Import data from Access to SQL Server? - sql-server

I'm asking for the proper way, in SQL Server's T-SQL (I think that's what it is) code or using another language, to import data from a Microsoft Access MDB Database into a new SQL Server Database.
Now, typically I would just import it in. The problem is I'm writing a .SQL script (I could use another technology if needed) to do all this leg work as this will need to be done fairly regularly. Likely at least once a week, for about 5 months in the year.
To digress a tad, I had wanted to implement a single database and distinguish separate source database using something like a DatabaseID field, but the powers that be overthrew me there.
I was previously using SQL Server Management Studio 2012 with SQL Server 2008 running the T-SQL (on a production machine) that worked fine. I've now migrated to a local SQL Server Management Studio 2012 with SQL Server 2012 (for development) and the code that used to work doesn't anymore.
This code is what used to work: SELECT * INTO [dbo].[Controls] FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0', 'Data Source=C:\Show.mdb; Jet OLEDB:Database Password=BobSaget')...[Control] The password has been obfuscated for security ...
That's likely a sloppy solution. What's the ideal way?
Thanks in advance!

I would recommend using Microsoft's SQL Server Migration Assistant for Access.
SQL Server Migration Assistant (SSMA) is a free supported tool from Microsoft that simplifies database migration process from Access to SQL Server. SSMA for Access automates conversion of Microsoft Access database objects to SQL Server database objects, loads the objects into SQL Server, and then migrates data from Microsoft Access to SQL Server.
SSMA for Access v5.2 is designed to support migration from Microsoft Access 97 and higher to all editions of SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012, and SQL Azure.
You can find it here.
You may need to fix the structure after the migration as it tends to over exaggerate many of the data types.

Have you checked your DCOM security on MSDAINITIALIZE?
I had this problem when moving to a local instance of SSMS 2012.
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2011/09/28/troubleshooting-cannot-create-an-instance-of-ole-db-provider.aspx

Related

AdventureWorks 2014 database for SQLite

For university purpose I need to use AdventureWorks 2014 sample database. What I can download is a .bak file to use with SQL Server, but I'm using DataGrip with SQLite on MacBook. How can I convert it or get it to work with my setup?
If you are required to use the AdventureWorks database for your course, you will need access to an instance of SQL Server. There is no way around this. You can install Developer or Express edition in a Windows VM on your MacBook, dual-boot Windows via Boot Camp, get access to a server on-campus, or set up a VM on Azure or AWS with SQL Server on it and restore the database there.
There is no way to use a SQL Server database backup file with SQLite or any other RDBMS that isn't SQL Server. Further, I expect that if your course requires this database for the assignments, "converting" it to SQLite isn't going to do you any good because of the differences between the two RDBMSs - they use different dialects of SQL and have different features.

Selecting data from SQL Server 2005 DB to Azure SQL staging DB table in Azure

I was wondering if this is possible: I want to create 2 tables in an Azure SQL database which I want to use as staging tables for some data selected from a SQL Server 2005 database on an on-premise server.
Is there any good way of doing this?
Update:
Followed the Linked-Server Guide and got this error: I need to add a linked server to a MS Azure SQL Server
The weird thing is i just managed to login to the Azure DB on with Those exact credentials. Am i missing some security configuration somewhere?
You don't necessarily need to create a linked server to move data from an on-premise SQL table to Azure SQL. Tools like SSIS come to mind, where a linked server isn't necessary. Or a tool like SSDT where you could use the Data Compare feature to move data. There is also Azure Data Factory.
Support for linked servers and distributed queries against a SQL Azure Database is a feature available since September 2012 as explained here. On my tests it does not work correctly on SQL 2012 and does not work on SQL Server 2008 R2 and earlier versions. You may need to upgrade to SQL Server 2014 to create a fully functional linked server.
Hope this helps.

Syncing a SQL Server CE database with a regular SQL Server database

There's an Umbraco site that various people been contributing content to. It runs on a hosted domain using a SQL Server Compact edition database for the CMS. It's about to go live and I need to sync the dev database to the live SQL Server instance which is hosted by a third party.
I just ass(u)me(d) that I could attach the .sdf to my local SQL Server and use a commercial tool (Redgate/SQLDelta etc.) to copy it to the live db. This does not seem to be possible. While I have managed to attach the .sdf using Linqpad, I can't connect to it like a regular database.
The best option seems to be to script out the entire database, but this seems like an impossible task using just Linqpad (no flies on Linqpad, obviously - it isn't the tool for such a task). Any less onerous options would be gratefully accepted.
You can use my free "SQL Server Compact Toolbox" Visual Studio extension for this. It can generate a script of the entire SQL Server Compact database, that you can then run against an empty SQL Server database.
In the past I did this kind of scenario wherein I need to copy the data from the SQL Server CE to a SQL Server database. Have you tried adding the .sdf to an ODBC then linked that ODBC to SQL Server?

What will be missed if report server 2008R2 database gets restored in SQL server 2014

I'm planning to migrate all the SSRS reports from 2008R2 server to new sql server 2014 environment. As far as migration is concerned, I was asked to take the backup of 2008R2 report server database and restore it in 2014 server.
I was not convinced with this since there may be new tables available in 2014 Report server.
The new features of 2014 cant be utilized if the old report server database is restored.
Please let me know if this thought is correct.
Are there any new tables available in 2014 report server database?
What is the best option to migrate ssrs reports from 2008 r2 to 2014 server?.
Your question is a bit confusing, I will assume you want to move the database from a Server A with SQL Server 2008R2 + SSRS 2008R2 to a Server B with SQL Server 2014 + SSRS 2014.
Are there any new tables available in 2014 report server database?
There is no official communication on it.
If you really want to know it you could do a schema compare between the 2 versions.
But do not forget to compare everything, not only tables:
Columns
Stored Procedures, Functions
...
Database structure is not the only thing to take into account, what about:
All the configuration files
Encryption Keys
...
What is the best option to migrate ssrs reports from 2008 r2 to 2014
server?.
Short answer:
My recommended way of doing it would be to use RS Scripter and generate a script on Server A with all the objects (reports, datasources, subscriptions, ...) you want to move.
Then you can restore it on Server B.
Long answer:
If you really want to migrate the full database like you were asked to do, there is no officially supported way to move the database to another SQL instance and upgrade the version at the same time.
You could try to follow the steps to Backup and Restore Operations for Reporting Services, and apply it to a newer SQL Server instance with another SSRS version, but it will be at your own risk.
The supported ways to do would be to either:
Upgrade from SSRS 2008R2 to SSRS 2014 on Server A
Move from Server A to Server B
or
Move from Server A to Server B
Upgrade from SSRS 2008R2 to SSRS 2014 on Server B
Here are the related MSDN articles for these operations:
Migrate a Reporting Services Installation (Native Mode)
Upgrade to SQL Server 2014
Again, I would advise using a tool to migrate the reports and other items instead of trying to migrate the full database.
I do not think restore 2008R2 reportserver db on 2014 will work, because the report definition schema is totally different.
I did a migration task to move 2008R2 reports to 2012. Because there are hundreds of reports on the 2008R2 server, I found the easiest way is to write some codes to read report definition, and then create on 2012 server.
From: https://msdn.microsoft.com/en-us/library/ms143747.aspx
There are two general approaches to upgrading a Reporting Services
deployment:
Upgrade: You upgrade the Reporting Services components on
the servers and instances where they are currently installed. This is
commonly called an “in place” upgrade. In-place upgrade is not
supported from one mode of Reporting Services server to another. For
example, you cannot upgrade a Native Mode report server to a
SharePoint mode report server. You can migrate your report items from
one mode to another. For more information, see the ‘Native to
SharePoint Migration’ section later in this document.
Migrate: You
install and configure a new SharePoint environment, copy your report
items and resources to the new environment, and configure the new
environment to use existing content. A lower level form of migration
is to copy the Reporting Services databases, configuration files, and
if you are using SharePoint mode, the SharePoint content databases.
If you do an in-place upgrade from SQL Server 2008R2 to SQL Server 2014, then everything should work as expected.

Database created in XP to be opened on Vista

I have a database in SQL server which is created on xp and to be opened on vista
When i try opening it on Vista.
Would this be possible
Thanks
Sun
SQL Server creates files that SQL Server can read. The file formats are independent of Windows versions.
What you should be aware of/considering are SQL Server versions and editions.
For instance, if you create a DB using SQL Server 2008 R2, you will not be able to attach/restore such a database using SQL Server 2005 or 2008, no matter what OS you're working on.
Similarly, if you've applied a particular service pack to the installation where the .mdf originates, you need to be working at the same or later service pack on the system where you want to read the file.
Similarly, if you create a database that uses features that are only available in higher level editions of SQL Server - i.e. something only available in Enterprise/Developer edition - you may have issues using the same database on a Standard Edition installation.
You don't open a sql server database with "xp" or "vista". You open the database in Sql Server. That's all that matters here: does the machine have the correct version of Sql Server available? Note that no version of Windows ships with Sql Server installed by default.
Also, unless you're talking about Sql Server Compact Edition you might want to re-think this. Full editions of Sql Server belong on the server editions of Windows. If you're building a database for an app that will live on individual user's desktop and the database will only serve the instance of the app on the machine, do not use sql server for that database. Instead, use something like Sql Server Compact Edition (it uses a different engine than full sql server that is more desktop-friendly), SQLite, or even Access.
Yes, there is no reason why this should not work.
As #Demian said, you can not open database created in SQL Server 2008 R2 in SQL Server 2008. But alternatively if you are sure that your database is not using any features specific to R2, you can script out whole database and then create similar database by running those scripts into SQL Server 2008 (ofcourse with some changes in script). And then just write some insert scripts to import data from 2008R2 to 2008 (Or you can use SSIS to dump data from one location to another location)
I think the question itself is pretty unclear. No explaination of environment of both XP and Vista machines (e.g. DBMS versions including SPs) or how you are trying to open/access database (using attach or by restoring backup). Without proper information I don't think there is any EXACT solution.

Resources