Error Importing DB from SQL Azure to a localDB - sql-server

I have a SQLPaaS instance which we have exported into a .bacpac file. When I try and import the .bacpac into my local SQL Server 2017 CU14, I am getting an error on an ExternalDataSource, I do not need this external data source so I am trying to figure out a way to import this .bacpac.
I have tried using sqlpackage.exe (the import action doesn't let you exclude types, and the publish action requires a .dacpac not a .bacpac).
The error is:
Error importing database:Could not import package.
Error SQL72014: .Net SqlClient Data Provider:
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'RDBMS'.
Error SQL72045: Script execution error. The executed script: CREATE EXTERNAL DATA SOURCE [LocalLoopBack]
WITH (
TYPE = RDBMS,
LOCATION = N'xxxxxx.database.windows.net',
DATABASE_NAME = N'xxxxxxx',
CREDENTIAL = [xxxxxx]
);
Is there anyway I can get this to import?

Can you copy that Azure SQL Database with a new name using Azure portal as explained here?
Remove the external data source from the new database and then export it as bacpac. Delete the newly created database with the copy operation. Import the bacpac created to your localDB instance.

Related

Import Wide World Importers DB into Azure Data Studio

I would like to import the sample WideWorldImporters-Full.bacpac database from:
https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImportersDW-Standard.bacpac
into Azure Data Studio 1.32 for Windows 10. I am using the Data-tier Application Wizard -> Create a DB from a .bacpac file. I get the following error which has stumped me:
Import bacpac: Could not import package.
Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 5105, Level 16, State 2, Line 1 A file activation error occurred. The physical file name 'WideWorldImportersDW-Standard_USERDATA_B694BC2.mdf' may be incorrect. Diagnose and correct additional errors, and retry the operation.
Error SQL72045: Script execution error. The executed script:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [USERDATA_B694BC2], FILENAME = N'$(DefaultDataPath)$(DefaultFilePrefix)_USERDATA_B694BC2.mdf') TO FILEGROUP [USERDATA];
Error SQL72014: Core Microsoft SqlClient Data Provider: Msg 5009, Level 16, State 8, Line 1 One or more files listed in the statement could not be found or could not be initialized.
Error SQL72045: Script execution error. The executed script:
ALTER DATABASE [$(DatabaseName)]
ADD FILE (NAME = [USERDATA_B694BC2], FILENAME = N'$(DefaultDataPath)$(DefaultFilePrefix)_USERDATA_B694BC2.mdf') TO FILEGROUP [USERDATA];
Any help would be appreciated
I followed the same MS document and was able to import the WideWorldImporters-Full.bacpac database successfully using Azure data studio.
Please make sure you provide correct file location in Step2 to import the dacpac file.

PostgreSQL TDS_FDW connection to pull in SQL Server metadata

Creating a metadata repository in PostgreSQL but am having difficulty with TDS_FDW and attempts to import SQL Server's INFORMATION_SCHEMA tables.
Using tds_fdw version 2.0.0-alpha.3
When I try to import "master", TDS_FDW produces a syntax error:
postgres=# IMPORT FOREIGN SCHEMA master FROM SERVER sql002 INTO public OPTIONS (import_default 'true');
ERROR: syntax error at or near ")"
LINE 2: ) SERVER sql002`
If I run a test import schema using dbo, it works fine, but INFORMATION_SCHEMA doesn't exist
What would be a functional way to pull the database and column names from SQL Server into PostgreSQL? (It's been ages since I was a SQL Server dba)

Azure Import Error: The internal target platform type SqlAzureV12DatabaseSchemaProvider does not support schema file version '3.1'

For some reasons I cannot import new BACPACs from Azure. I still can import old ones.
This is the error message I get:
Internal Error. The internal target platform type SqlAzureV12DatabaseSchemaProvider does not support schema file version '3.1'.
I've tried this this solution , but it didn't help, because all my settings are already set up to default.
I also downloaded latest SSMS Preview, but on import it gives me other errors:
Warning SQL0: A project which specifies Microsoft Azure SQL Database v12 as the target platform may experience compatibility issues with SQL Server 2014.
Error SQL72014: .Net SqlClient Data Provider: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'Admin'.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE SCOPED CREDENTIAL [Admin]
WITH IDENTITY = N'Admin';
Error SQL72014: .Net SqlClient Data Provider: Msg 319, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Error SQL72045: Script execution error. The executed script:
CREATE DATABASE SCOPED CREDENTIAL [Admin]
WITH IDENTITY = N'Admin';
I have SSMS 2014 CU6 installed.
Any help would be much appreciated! Thank you!
Finally figured out what happened. It's a specific case, but maybe it helps someone else.
We tried to use elasic query to write queries across databases. To do it you need to create database scoped credentials. When package was imported, it tried to do the same locally and failed executing this:
CREATE DATABASE SCOPED CREDENTIAL [Admin]
WITH IDENTITY = N'Admin';
Since we decided to use different approach, I dropped scoped credentials and external data source (couldn't drop credentials without dropping data source):
DROP EXTERNAL DATA SOURCE Source
DROP DATABASE SCOPED CREDENTIAL Admin
Now everything is working again. Just be aware you cannot import database from Azure if it has scoped credentials created.
Make sure that you are using the new SQL Server Management Studio
https://msdn.microsoft.com/en-us/library/mt238290.aspx

SQL Server Import OLE DB error 0x80040E09

I just installed SQL Server 2014 and now I'm trying to import an Access database. To do the import I use the SQL Server 2014 Import and Export Data Wizard. I can go trough all steps of the wizard except the step below, which gives me this error.
The red underlined text is Dutch the translation for this line is: Cannot read the records. U don't have permission for tblAanmaningHistorie to read the data.
tblAanmaningHistorie is the first table in the Access database, when I try to import other tables I get the same error.
Data source screen
How to fix this?

Trying to Import FoxPro DBF File to SQL Server

As the title says, I'm trying to import a FoxPro dbf file into sql server using openrowset. At first I tried to export the DBF to an xls file and import using the Import/Export wizard. This works pretty well normally, but there is one field that sometimes holds a really long string, and this string is being truncated at 4096 characters during the export from the dbf to xls.
I found an old post with instructions on how to do this using openrowset.
When I try the first answer:
select *
from openrowset('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;
SourceDB=\\path\;
SourceType=DBF',
'select * from TABLE.DBF')
I get the error:
OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".
When I try the second answer:
select *
from openrowset('VFPOLEDB',
'\\Path\';'';'',
'select * from TABLE.DBF')
I get the error:
Msg 7403, Level 16, State 1, Line 1
The OLE DB provider "VFPOLEDB" has not been registered.
I tried to register the OLE*.dll files manually with regsvr32, but only some of them worked. On ole32, oleacc, oleaut32, and oleprn I got a success message. On oleacchooks, oleaccrc, oledlg, and oleres I got this error:
The module "oleacchooks" was loaded but the
entry-point DllRegisterServer was not found.
Make sure that "oleacchooks" is a valid DLL or OCX file
and then try again
After some investigation I tried to install the componet, but when I tried to install the msi file for FoxPro (found here), I got this error:
An error occurred while processing the last operation.
Error code 80110408 - Error occurred reading the application file
The event log may contain additional troubleshooting information.
So, I'm officially lost here. Does anybody have suggestions on how to get openrowset to work, or some other way of importing the dbf file?
Pat, you can use DBF Commander Pro for this task.
Download it, install, then click File -> Export to DBMS. In the window appears click Build button in order to build the connection string: select MS OLEDB Provider for SQL Server, then choose your server from the list, provide login and password, select a database, click OK:
In the Export to DBMS window select the destination table you want to import source DBF file to, then click Export.
More info on import and export DBF to a database you can find here.
P.S. The app has fully functional free trial 20-days period.
Try using VFPOLEDB.1 as the provider. You may be experiencing driver version issues.

Resources