Jess31
asked on
SQL Server / Update DB?
I have a db on a 2012 server. I have the same db on a 2016 server. I made changes to the one on the 2016 server. Now I want to update the 2012 with my 2016.
I have rights to this specific db on the 2012 but I'm not sure if I remove this db that I would right to create it again. On the 2016 I have full rights for everything.
How do I do this?
I have rights to this specific db on the 2012 but I'm not sure if I remove this db that I would right to create it again. On the 2016 I have full rights for everything.
How do I do this?
ASKER
any stored procedures or function that have been added or changed, same with tables
If you want to perform this only once, then best thing to do is to script the changed objects and run the script in the SQL Server 2012 instance.
If you want to perform this in a regular way, set a Replication between SQL Server 2016 database and the respective DB in SQL Server 2012. When you have a new object just add it to the articles so it can be replicated.
If you want to perform this in a regular way, set a Replication between SQL Server 2016 database and the respective DB in SQL Server 2012. When you have a new object just add it to the articles so it can be replicated.
ASKER
I tried using the script database. But when I run it on the 2012 I get these errors "There is already an object named..." Is there away to have the script override any existing object?
If you script changed objects from SQL Server Management Studio, you should script with DROP and CREATE option. But if an object is existing on 2012 and some users are granted permissions on the object, you will need to grant again after updating.
If 2012 database is still used for LIVE environment, you should have a backup strategy for the objects before modifying them.
If 2012 database is still used for LIVE environment, you should have a backup strategy for the objects before modifying them.
ASKER
Is it possible to create bacpac on 2016 and import it in 2012?
Or you could simply purchase SQL Compare from Red-Gate and let that app take care of all the dependencies.
I tried using the script database. But when I run it on the 2012 I get these errors "There is already an object named..." Is there away to have the script override any existing object?You can configure the script to bypass or drop existing objects. What do you prefer?
ASKER
I recreated the db on the target server. I created the scripts and ran it on the target. The Tables and stored procedures/functions seems to have been creted.
But I got errors on these lines in the script and the diagram didn't get created
ALTER DATABASE [ShipBill] SET TRUSTWORTHY OFF
ALTER DATABASE [ShipBill] SET HONOR_BROKER_PRIORITY OFF
ALTER DATABASE [ShipBill] SET DB_CHAINING OFF
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMAT ION = OFF;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMAT ION = PRIMARY;
ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
But I got errors on these lines in the script and the diagram didn't get created
ALTER DATABASE [ShipBill] SET TRUSTWORTHY OFF
ALTER DATABASE [ShipBill] SET HONOR_BROKER_PRIORITY OFF
ALTER DATABASE [ShipBill] SET DB_CHAINING OFF
ALTER DATABASE SCOPED CONFIGURATION SET MAXDOP = 0;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET MAXDOP = PRIMARY;
ALTER DATABASE SCOPED CONFIGURATION SET LEGACY_CARDINALITY_ESTIMAT
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET LEGACY_CARDINALITY_ESTIMAT
ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = ON;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET PARAMETER_SNIFFING = PRIMARY;
ALTER DATABASE SCOPED CONFIGURATION SET QUERY_OPTIMIZER_HOTFIXES = OFF;
ALTER DATABASE SCOPED CONFIGURATION FOR SECONDARY SET QUERY_OPTIMIZER_HOTFIXES = PRIMARY;
ASKER
the script I created I had set to version 2012. I also set my db to compatibly 120 which is for 2012
That's strange because for example, this command only exists in SQL Server 2016 as you can state by the MSDN article.
ASKER
I just tried generate scripts again, using 2012 target, but this time only fore Schema and it put this scopped configuration in as well.
Might be some kind of bug then. Can't you just remove those lines from the script?
ASKER
I had done that and all seemed fine. But I'm wondering why the Diagrams didn't get created. Is it not suppose to be?
You are only script the objects and not importing the data, right?
Check if table sysdiagrams has records or it is empty.
Check if table sysdiagrams has records or it is empty.
ASKER
I generated scripts for both Schema and Data. Both seemed to import fine despite the errors mentioned about.
sysdiagrams in my source contains 5 rows, in the target 0
sysdiagrams in my source contains 5 rows, in the target 0
ASKER
Yes, only sysdiagrams didn't import.
The Export data you show - can I use it to just export diagrams?
The Export data you show - can I use it to just export diagrams?
Yes, you can. Just choose the table instead of all objects.
ASKER
Export Data wants me to specify another db or such like to export it to. But the db to which I am looking to copy it is on another non connected computer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Whole database? Some stored procedure or function? Some tables? Data only?