Cannot import SQL Azure bacpac to 2016 CTP - sql-server

I'm very familiar with the process of exporting from Azure SQL V12 down to my dev box and then importing to my local sql (2014) instance. I'm spinning up a new Win10 box and have installed the SQL 2016 CTP. I'm connecting to that same Azure instance and can operate against it -- and can export a .bacpac just as with 2014.
But when I try to import to local I'm getting:
Could not import package.
Warning SQL72012: The object [FOO33_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Warning SQL72012: The object [FOO33_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.
Error SQL72014: .Net SqlClient Data Provider: Msg 547, Level 16, State 0, Line 3 The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_dbo.Address_dbo.User_idUser". The conflict occurred in database "FOO33", table "dbo.User", column 'idUser'.
Error SQL72045: Script execution error. The executed script:
PRINT N'Checking constraint: FK_dbo.Address_dbo.User_idUser [dbo].[Address]';
ALTER TABLE [dbo].[Address] WITH CHECK CHECK CONSTRAINT [FK_dbo.Address_dbo.User_idUser];

Since this question was also asked and answered on MSDN, I will share here.
https://social.msdn.microsoft.com/Forums/azure/en-US/0b025206-5ea4-4ecb-b475-c7fabdb6df64/cannot-import-sql-azure-bacpac-to-2016-ctp?forum=ssdsgetstarted
Text from linked answer:
I suspect what's going wrong here is that the export operation was performed using a DB instance that was changing while the export was on-going. This can cause the exported table data to be inconsistent because, unlike SQL Server's physical backup/restore, exports do not guarantee transactional consistency. Instead, they're essentially performed by connecting to each table in the database in turn and running select *. When a foreign key relationship exists between two tables and the read table data is inconsistent, it results in an error during import after the data is written to the database and the import code attempts to re-enable the foreign key. We suggest using the database copy mechanism (create database copyDb as copy of originalDb), which guarantees a copy with transactional consistency, and then exporting from the non-changing database copy.

Related

Oracle to MSSQL migration error 'The table xxx doesnot exist in target'

I am trying to convert and migrate an Oracle schema to MSSQL server. At the last step, migrating data, I get the error message:
The table [MYDATABASE].[MYSCHEMA].MYTABLE] doesnot exist in target. You must first convert the table then load it into the database.
This error message appears for each table in my schema.
Can someone explain what is happening and what I need to do to get past this?
Are you tries to migrate the data before doing the ‘synchronize with the database’ operation?
If Yes,
This error message generally occurs when the target table doesn’t
exist on SQL server database. After converting schema, you need to
synchronize the table with the database before migrating the data.
To do this you right click on the SQL Server database in Metadata
explorer and click “Synchronize with database” menu.
Note: Table structure will not be created in the SQL server database until you synchronize.

Adding Full Text Catalog to VS2013 causes build errors in SQL database project

I want to use my DB project to contain the definition of my full text catalog and its indexes. I've added the catalog to my SQL server instance and created an index
CREATE FULLTEXT CATALOG [FTSCatalog]
WITH ACCENT_SENSITIVITY = ON
AS DEFAULT
AUTHORIZATION [username_UAT];
with the index
CREATE FULLTEXT INDEX ON [dbo].[tablename]
([ColumnName] LANGUAGE 1033)
KEY INDEX [PK_tablename]
ON [FTSCatalog];
However, the SQL DB project gives an error on the definition of FTSCatalog
Error 2 SQL71501: Full-text Catalog: [FTSCatalog] has an unresolved reference to object [username_UAT]
Using the SQL database schema compare tool to synchronise the user generates a user file that contains this:
CREATE USER [username_UAT] FOR LOGIN [username_UAT];
The error now moves to this file, but it contains an oddly looking circular reference. The error is now on the second occurrence of username_UAT:
Error 2 SQL71501: User: [username_UAT] has an unresolved reference to Login [username_UAT]
In the schema compare options object types I have Users, Full-Text Catalogs and Full-Text indexes checked. There is no option to synchronise logins.
How do I get the definition of my full text catalog into my SQL DB project?
This stackoverflow question gave me the answer:
How to create a user for a login in 2013 SQL Server Database Project
I had to check the "logins" checkbox on the Non-Application scoped section of the compare options object types.

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

Store spss data on SQL database based on uniqueidentifier

I Imported a table from SQL database to SPSS dataset, I edited the table by adding a new column to it after some statistics, but when I try to export the table back to the database by adding the new column, by matching the Primary key from dataset and database table which is of type "uniqueIdentifier, this error is shown to me
> Error # 6492
>The ODBC subsystem has issued an error which prevents the processing of SAVE
>TRANSLATE ODBC request.
>Execution of this command stops.
>[Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when
>converting from a character string to uniqueidentifier.
how to resolve this error?
uniqueidentifier is probably a type that the ODBC driver doesn't know how to convert to as it is probably a database internal type. Try writing your data to a new table without converting and then do an update of the database table from within the database converting the identifier type inside the database. You can put the necessary SQL in your SAVE TRANSLATE syntax using its SQL subcommand.

Error in export sql server database

I have SQL server and SQL management studio 2012. After i create tables and when i export the data base to the server "online" every "primary and auto incremental" field become as a normal field. so when i try to add row to database i have the following error
"Cannot insert the value NULL into column 'taskID', table 'lawyersDB.dbo.tasks'; column does not allow nulls. INSERT fails.
The statement has been terminated."
To solve this problem i have to manage the database "online" and go to each table and set again the fields primary and auto incremental. Since i have many tables, this process takes lot of time.
So Any idea to solve this problem!?
Note: my hosting is on Arvix company server
This is SQL Management Studio, not your account.
Try this:
You need to set this, or else if you have a non-nullable column, with no default error, if you provide no value it will error.
To set up auto-increment in SQL Server Management Studio:
Open your table in Design
Select your column and go to Column Properties
Under Indentity Specification, set (Is Identity)=Yes and Indentity Increment=1

Resources