We have a Chain store environment using SQL replication. For upgrading the SQL Server we will remove the replication components from the stores and will do the SQL upgrade and then will add the stores back to the Chain. The problem here is SQL Server is not upgrading from 2008 R2 to 2012 as the is_subscribed flag is 1. As I am aware of the is_subscribed flag is no longer used in SQL Server and was using on and before 6.5. I doubt the customer might be carrying the database from then and it is throwing the issue now in SQL 2012. The question is how to update the flag to 0. We can run the upgrade only if this is set to 0. I have tried executing sp_dropsubscripion and sp_removereplicationdb. But no luck. Any help will be much appreciated.
Please use the below code
EXEC sp_dboption 'DBName','subscribed',FALSE
Related
I am successfully doing a daily restore of a backup from an earlier version onto MS SQL 2017 using T-SQL.
However during the restore the database gets upgraded to the current version.
This is a problem as I wish to modify the database and then do a backup which then gets transferred and restored to another system which is using the same earlier version of MS SQL.
Is it possible to run the RESTORE without the database getting upgraded?
Have been looking through T-SQL documentation and not found this referred to.
The T-SQL code I am using is:
USE master
GO
ALTER DATABASE Polly SET SINGLE_USER
with ROLLBACK IMMEDIATE
GO
RESTORE DATABASE Polly FROM DISK = 'C:\data\Polly.bak';
GO
USE Polly
DELETE FROM SytLog;
GO
ALTER DATABASE Polly SET MULTI_USER
GO
If anyone has general improvements to above I am happy for suggestions.
When the above runs I get:
Database 'Polly' running the upgrade step from version 782 to version 801.
...
Database 'Polly' running the upgrade step from version 868 to version 869.
Would like to see no upgrade steps, but only if database still usable.
When the above runs I get: Database 'Polly' running the upgrade step
from version 782 to version 801. ... Database 'Polly' running the
upgrade step from version 868 to version 869.
Would like to see no upgrade steps, but only if database still usable.
This is not possible. Every version of SQL Server has its data and log files structure that differs between server versions. And if you restore or attach database from lower version db files are one-way updated to have a structure that the current version of SQL Server needs.
It's impossible to not upgrade because the current version of server needs that new structure for db files.
All speculations around compatibility level / read_only property will not help at all, current server will never run with files that are not of the structure it needs.
In case of readonly database its files will be upgrade but the database will remain readonly.
Compatibility level has nothing to do with database version (version of db files) at all. It just tell to server what version of query optimizer should be used, what legacy syntax can still be parsed, etc.
No, this isn't possible. Once a database is attached to a newer version of SQL Server, you can't move it back to older. The only option in this case is to export/import the data. If you need to modify the database and move it back to the older server, you need to install a server with the same old version and do the restores there!
Microsoft documentation states:
If you restore a SQL Server 2005 (9.x) or higher database to SQL Server 2017, the database is automatically upgraded.
Although I would try in case of desperate need to create read-only database and restore it.
But this is kind of black magic not directly supported by vendor.
The compatibility level is important.
Even when the compatibility level of the database needs to be changed, under certain conditions the backup can’t be simply restored.
Restoring a database backup created on a SQL Server 2008
R2 to a SQL Server 2012 instance goes smoothly, but if a SQL Server
2000 backup is tried to be restored on a SQL Server 2012 you cannot
directly do it.
Recently, we migrated the servers from SQL Server 2012 to 2016. Without any changes, a few of the queries got performance degraded.
If I run the query in SQL Server 2012, it takes 10 seconds, but the same query takes 50+min in SQL Server 2016.
If I updated the SQL Server 2016 database with Legacy CE = ON then I am able to get the results very quickly as same as 2012. But I believe it's not recommended to use Legacy CE ON in SQL Server 2016.
ALTER DATABASE SCOPED CONFIGURATION SET
LEGACY_CARDINALITY_ESTIMATION = ON;
I also updated the statistics of all tables, even thought I did get any improvement in execution.
So, Is this related to DB configuration issue (or) really do I need to update the query?
I am not sure, which configuration details I need to check. Could you please suggest anything?
Thanks advance..
solution: Link1 /
Link2
Route cause : CARDINALITY_ESTIMATION
Thanks to all.
I have installed SSMS2017, i don't see Query Store page under db level properties.
I also tried through command line query:
alter database <db_name> SET QUERY_STORE = ON;
this doesn't seem to be working either.
Could someone please help on how can i enable query store ?
Thanks.
Upgrading SSMS alone won't work, you need both SQL Server 2016+ as well as latest SSMS to support viewing Query Store Options.
-- Major Build Version is 13 for SQL 2016 and 14 for SQL 2017
SELECT ##VERSION
I don't have the management studio installed and cannot install the express version as there seems to be a problem with my computer set up.
However I have VS2013 and I can open up query windows.
I created Indexes but then since then I have added a lot of new data. Is there some way I can update statistics for my SQL Server 2012 database from the SQL Script command line?
Try EXEC SP_updatestats to update all database statistics.
You can access the SQL command line using the tool sqlcmd that is installed as part of SQL 2012.
Here's a link to the update statistics command that you'll need to put together and execute.
http://technet.microsoft.com/en-us/library/ms187348.aspx
You can always create a script for the update statistics command, then execute that.
If you have both SQL and SQL Express installed, please make sure that you are connecting to the correct instance of SQL Server. the machine name alone or localhost should take you to the full sql 2012, (the default instance name for this is MSSQLSERVER) and the SQL Express should have an instance name of SQLEXPRESS (if I remember correctly) you'll need to use the naming convention server\instance to make the connection (you probably knew this bit already)
Try this
EXEC sp_updatestats;
MSDN
I have a database which was upgraded from 2000 to 2005. Is there any issue using sp_dbcmptlevel to change compatibility level to 90. Will this cause any issues with old queries or stored procedures
Did you run the SQL Server upgrade adviser on the old database? It will tell you if there is any obvious problems. Be sure to test on a development database.
Here is the tool
http://www.microsoft.com/downloads/details.aspx?FamilyID=1470e86b-7e05-4322-a677-95ab44f12d75&displaylang=en