Quantcast
Channel: SQL Archives - SQL Authority with Pinal Dave
Viewing all 599 articles
Browse latest View live

SQL SERVER – Data Lineage Tracking in ETL Processes – Notes from the Field #124


SQL SERVER – FIX: SQL Profiler Error – Cannot Retrieve Trace Definition for SQL Server Version

$
0
0

As soon as I opened profiler and clicked on “connect” button, I was welcomed with below the message box. This is one of the funniest error message which I have seen from long time. There is no message!!! Let us see how to fix SQL Profiler Error.

Hitting OK on above, came to below message.

The version shown in the message 13.0.900 is the version of my SQL instance (SQL Server 2016 CTP) on which I was connecting. Here is the text of the second error message.

The post SQL SERVER – FIX: SQL Profiler Error – Cannot Retrieve Trace Definition for SQL Server Version appeared first on Journey to SQL Authority with Pinal Dave.

Comparison – Logical Architecture between Oracle and SQL Server

$
0
0

Learning is a journey and that is something I love to keep in mind. Even after being so many years in the industry, I don’t stop learning from peers and people around me. This is the best way I can get better at something. I have been writing about the comparisons working with Oracle and SQL Server in the past and I personally thought this was a great way to learn something new by understanding the concepts of something that we always know. The learning is easy when we are able to make an analogy or metaphor as part of our learning. Do you guys ever use a similar approach while learning something that is completely new in your day-today life? Let us learn about Logical Architecture today.

The post Comparison – Logical Architecture between Oracle and SQL Server appeared first on Journey to SQL Authority with Pinal Dave.

SQL SERVER 2016 – Management Studio Highlighting Current Line Option

$
0
0

With every new release, there is changes that are being made to the tools that support it. It is tough sometimes to keep up with the pace. I am always an old school guy and I try not to change the style that involves changes to the way things function. When I installed SQL Server 2016 Management Studio, there was something fresh about the IDE, but I was trying to get to terms to why I was feeling little weird. Let us learn about Highlighting Current Line Option in SSMS 2016.

The post SQL SERVER 2016 – Management Studio Highlighting Current Line Option appeared first on Journey to SQL Authority with Pinal Dave.

PowerShell – Querying SQL Server From Command Line

$
0
0

PowerShell is quite an interesting capability that is added as part of Windows. I wonder how many of us really appreciate the power of this tool being out of the box. The more I see it being used in customer locations, the more I get intrigued by what it can do. Let us learn about Querying SQL Server From Command Line via powershell.

In a recent consulting assignment, I saw the development team use interesting methodology to do their code deployment. They were using PowerShell scripts to actually do the code deployment on various servers. While they were moving from one environment to another like from Dev to Test to Integration of Production, they were changing just a single parameter.

The whole thing got me interested. I asked how they were able to get this achieved. What happens to the environment specific variables, values? The Dev guy turns around and told me – “Pinal, everything is in safe hands of SQL Server”. As I stared at him with amusement, he opened up an Config Database and started showing how the trivial (though critical) values are stored in the database. They were using PowerShell to actually query these values and use it effectively in their script.

Watching the script I saw them using: Invoke-SqlCmd. This is when I started to see how powerful PowerShell scripts can be made using some out-of-box tools even without installing SQL Server on a box. I created a small script below to show how we can query a DMV and the output is put in the window.

Invoke-SqlCmd -Query "Select * from sys.databases" -ServerInstance "." 

PowerShell - Querying SQL Server From Command Line QueryDB-PowerShell-01

As you can see, the output is like what you would see inside an SSMS but in a property and value mode. This is repeated for all the databases inside the test instance of mine.

Have you ever had an opportunity to build such scripts in production environments? I would love to learn from you on how you maximized the use of Invoke-SqlCmd in your environment. Please use the comments below to let me know. Is this something new for you?

Reference: Pinal Dave (http://blog.SQLAuthority.com)

The post PowerShell – Querying SQL Server From Command Line appeared first on Journey to SQL Authority with Pinal Dave.

SQL SERVER – FIX: Error 1807 Could not obtain exclusive lock on database ‘model’. Retry the operation later – Part 2

$
0
0

I have always mentioned in the blogs that the most sought out blogs would be around troubleshooting or around specific error messages. These blogs are the biggest source of page views from various search engines. I love getting these error messages and an opportunity for me to learn something new. Here is my first blog written in the year 2010 and I still get questions around the blog via emails. FIX: Error: 1807 Could not obtain exclusive lock on database ‘model’. Retry the operation later. Let us learn to fix error 1807 in this blog post.

The blog is still relevant in SQL Server 2016 and the basics don’t change much between versions. Here is the error 1807.

Msg 1807, Level 16, State 3, Line 1
Could not obtain exclusive lock on database ‘model’. Retry the operation later.
Msg 1802, Level 16, State 4, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

SQL SERVER - FIX: Error 1807 Could not obtain exclusive lock on database 'model'. Retry the operation later – Part 2 model-in-use-01-800x169

There is already a connect item on Microsoft site that you can use for reference.

And as per Microsoft:

The exclusive lock on the model database is a necessary step to create a new database. When SQL Server creates a new database, “The SQL Server uses a copy of the model database to initialize the database and its metadata”. Also, users could create, modify, drop objects in the Model database. As such, it is important to exclusively lock the model database to prevent copying the data in change from the Model database. Otherwise, there is no guarantee that the content copied from the Model database are consistent and valid.

Why I am Writing Part 2 for Error 1807?

I realized that the solution given in an earlier blog is not working for most of my readers. Earlier solution was “Disconnect and Reconnect your SQL Server Management Studio’s session.”

If there is someone else grabbing the connection to model database, then above would not work. So, we need to do below:

  1. Find who is having connection? Below query can help in that.
IF EXISTS (
		SELECT request_session_id
		FROM sys.dm_tran_locks
		WHERE resource_database_id = DB_ID('model')
		)
BEGIN
	PRINT 'Model Database in use!!'

	SELECT *
	FROM sys.dm_exec_sessions
	WHERE session_id IN (
			SELECT request_session_id
			FROM sys.dm_tran_locks
			WHERE resource_database_id = DB_ID('model')
			)
END
ELSE
	PRINT 'Model Database not in used.'
  1. Kill the connection. Below query would provide KILL command which we can run to kill ALL connections which are using model database.
SELECT 'KILL ' + CONVERT(varchar(10), l.request_session_id)
 FROM sys.databases d, sys.dm_tran_locks l
 WHERE d.database_id = l.resource_database_id
 AND d.name = 'model'

Now, I feel the answer is more complete and this error can be easily mitigated. Do let me know if you ever encountered this error in your environments. More you share, more we learn together.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

The post SQL SERVER – FIX: Error 1807 Could not obtain exclusive lock on database ‘model’. Retry the operation later – Part 2 appeared first on Journey to SQL Authority with Pinal Dave.

SQL SERVER – Configuration Manager – MMC could not create the snap-in. The snap-in might not have been installed correctly

$
0
0

I have always felt the social media has a bigger impact on the current generation. It can easily spoil their time on one side or it can be awesomely productive if utilized the right way. As there are two sides to the coin, social media also have a similar effect on people. I have personally wanted to see the bright side because it gets access to people easier now. The space for being private has decreased and we can easily be web searchable. Whenever I get time, I try to help on public forums and even on my Facebook page of SQLAuthority. Recently, one of the friendliest contacted me with below error while opening configuration manager over Facebook. He was using SQL Server 2016 so I got excited and wanted to see what was the problem. We got into a Skype call and I was guiding him through the troubleshooting process:

SQL SERVER - Configuration Manager - MMC could not create the snap-in. The snap-in might not have been installed correctly mmc-snap-01

Here is an important informational error:

MMC could not create the snap-in CLSID: {EE7F2DDB-1319-4227-8FD4-4EB51615D34A}

Note: this trick should work with all MMCs failures. GUID depends on MMC. In this case it’s for SQL Server 2016.

MMC stands for Microsoft Management Console and can be opened via mmc.exe. One MMC is opened, we can load the snap-in.

SQL SERVER - Configuration Manager - MMC could not create the snap-in. The snap-in might not have been installed correctly mmc-snap-02

If you are not having “SQL Server Configuration Manager” in start menu, then you can add below shortcut.

C:\Windows\SysWOW64\mmc.exe /32 C:\Windows\SysWOW64\SQLServerManager13.msc

“SQLServerManager13.msc” in the above command is the Snap-in for SQL Server 2016. Below table shows the file name for previous versions.

SQL Server 2016 SQLServerManager13.msc
SQL Server 2014 SQLServerManager12.msc
SQL Server 2012 SQLServerManager11.msc

For this client, I have tried below: (again 130 is for SQL Server 2016)

mofcomp “%programfiles(x86)%\Microsoft SQL Server\130\Shared\sqlmgmproviderxpsp2up.mof”

Some site on internet asked to reset .net security. I have tried that also but it didn’t help.

C:\Windows\Microsoft.NET\Framework64\v2.0.50727> caspol.exe -all -reset

Finally, I have used Process Monitor and found that snap-in uses below registry key.

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MMC\SnapIns\{EE7F2DDB-1319-4227-8FD4-4EB51615D34A}

SQL SERVER - Configuration Manager - MMC could not create the snap-in. The snap-in might not have been installed correctly mmc-snap-03

We found that DLL was missing from that location. We found two solutions:

  1. Pick SQLManager.dll from another machine having the same version of SQL Server.
  2. Repair Shared components of SQL Server.

Since it was a test server, we went with option 1 and then we were able to open SQL Server Configuration manager. This is one more incident where tools like Process Monitor has helped me get to the bottom of the problem. Have you used Process Monitor to troubleshoot some issue? I am sure you will get innovative methods to use them.

Reference: Pinal Dave (http://blog.sqlauthority.com)

The post SQL SERVER – Configuration Manager – MMC could not create the snap-in. The snap-in might not have been installed correctly appeared first on Journey to SQL Authority with Pinal Dave.

SQL SERVER – Event ID 107- Report Server Windows Service (MSSQLSERVER) cannot connect to the report server database.

$
0
0

Generally, I like to pick and choose the way various services are installed when working with SQL Server. I am careful not to have unnecessary services like “Reporting Services”, “Agent” etc running. I install them and keep them in a switched off state because I don’t like to keep eating away the resources on my PC during startup. But this is more of a best practice in general, I see not many doing. Let us learn how we can fix the Event ID 107 error with Report Server.

Most of them have an attitude of going through the next button not watching what is shown on the screen during installation. I wanted to share this tip with you before jumping to the problem statement for the blog because I had to do some research before solving my customer’s problem stated below. This was the second time someone asked me a random question and I was determined to solve the same.

Error with Report Server

One of my clients reported an error which is the subject of the blog. In the event viewer they were seeing below error:

SQL SERVER - Event ID 107- Report Server Windows Service (MSSQLSERVER) cannot connect to the report server database. ssrs-01

Event Type: Error
Event Source: Report Server Windows Service (MSSQLSERVER)
Event Category: Management
Event ID: 107
Computer: SQLSERVER
Description:
Report Server Windows Service (MSSQLSERVER) cannot connect to the report server database

The error is generic because it doesn’t tell the exact error which is causing a connectivity error. My immediate question was that, are there any more errors? So, I asked them to look at Reporting Service Log file.

Report Server Windows Service (MSSQLSERVER) cannot connect to the report server database.
The application domain WindowsService_17 failed to initialize. Error: Microsoft.ReportingServices.Diagnostics.Utilities.ReportServerDatabaseUnavailableException: The report server cannot open a connection to the report server database. A connection to the database is required for all requests and processing.
System.Data.SqlClient.SqlException: Cannot open database “ReportServer” requested by the login. The login failed.
Login failed for user ‘MYDOMAIN\sqladmin’.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)

Here is the message on top of the stack, I have highlighted the error.

Resolution / Fix:

So I captured the profiler and found that the account used by not having permission to connect to the database. After giving permission we were able to start SSRS.

I learned something which is worth sharing. Here is the link which talks about the location of SSRS logs which has helped me in finding exact error message Reporting Services Log Files and Sources

Do you know the location of SSRS logs? Is there any other SSRS error you have seen? Share via comments.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

The post SQL SERVER – Event ID 107- Report Server Windows Service (MSSQLSERVER) cannot connect to the report server database. appeared first on Journey to SQL Authority with Pinal Dave.


SQL SERVER 2016 – How to Use SQL Server 2016 – Stretch Database – Notes from the Field #127

$
0
0

[Notes from Pinal]: First of all, last week SQL Server 2016 released. If you have not downloaded the developer version for free. You can download from here. SQL server 2016 has many different features which are related to performance and stability. One of the feature which attracted me very much is stretch database. I am sure of the name, you might have understood that it is about extending the current features of the SQL Server. Well, the feature is very interesting, and to understand how it works, you will have to read this entire blog post.

SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 Kenneth Linchpin People are database coaches and wellness experts for a data driven world. In this 127th episode of the Notes from the Fields series database expert Kenneth Urena (partner at Linchpin People) shares very interesting conversation related to how to use SQL Server 2016 new feature of Stretch Database.


Now that SQL Server 2016 is getting released, we all start asking our self, how can I utilize this new release of SQL Server to improve the company Database procedures. And one of the many features the product team decided to release this version of SQL server is, the ability to recover very very large databases quickly. And that is how Stretch Database enter to the game.

What is SQL Server Stretch Databases?

SQL Server Stretch is a technology introduced in SQL Server 2016 that allows to select tables (especially very large tables) and decide to keep part of the data in Azure Cloud and part of the data on premises. So yes, it is one of the first engagements from Microsoft to create a truly 100% integrated hybrid database.

Then essentially is to introduce the concept of keep cold data on the cloud and hot data on premises.

Are all the tables of my database eligible to be stretched?

Since it is the first delivery of this technology it had born with a lot of restrictions, so my recommendation is to download Microsoft SQL Server 2016 Upgrade advisor, and follow the next steps:

  1. Open the stretch Database Advisor
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-1
  2. Select the database to analyze
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-2
  3. Read the analysis report
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-3

As can be notice in the image 3, the sales table is not a candidate to be migrated to stretch databases, but the nice thing of the wizard is that It provides good insights of what can be done in order to make that table stretch; in this specific case is to remove a constraint.

Once I have an eligible table to be stretched, how can I start using this feature?

By Default, SQL Server 2016, or at least RC3 doesn’t come with stretch database enabled, then, in order to enable it you need to follow the next steps:

  1. Enable Stretch database at the instance level, don’t worry, by doing this you only are going to say to sql server “It is very likely that I plan to stretch some tables”.
use master
-- Enable stretch database at the instance level
exec sp_configure 'remote data archive', '1';
GO
RECONFIGURE
  1. Select the database you want to enable stretch databases.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-4
  2. Select the tables you want to enable stretch.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-5
  3. Once the table has been selected, you can stretch the entire table or click over “Entire table” link and define the criteria of what rows will get migrated.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-6
  4. Sign into the Azure account that will host the cold data.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-7
  5. Create a new server or use an existing one on azure.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-8
  6. Create a database master key.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-9
  7. Select the address where this database is going to be accessed, it could be also a network subnet range.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-10
  8. Review the summary data, including pricing in azure.
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-11
  9. Finally, the stretch database relationship gets stablished
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-12

Once Stretch database is configured how can be monitored and add tables, or pause migration?

To monitor the status of the migration, it can be in two ways.

  1. Using t-SQL
-- monitor syncronization status
select * from sys.dm_db_rda_migration_status
  1. By the Wizard, select the monitor item in the stretch menu
    SQL SERVER 2016 - How to Use SQL Server 2016 – Stretch Database - Notes from the Field #127 127-13

Modify the stretch status of a table

This can be done by altering the migrate_state to outbound or paused, as follows.

alter table T1 set (REMOTE_DATA_ARCHIVE = ON(MIGRATION_STATE=OUTBOUND));

Restore a database that is stretched

You must restore the database using the normal procedures of backup/restore, but since the must of the data reside in the cloud, at the end of the restore the link to the Azure database need to be re-stablish, and that can be done with the follow command:

  1. Make sure you save the credential name, this can be get with the following t-sql
select name from sys.database_scoped_credentials
  1. Re-stablish the link as follow
exec sp_rda_reauthorize_db @credential = N'credential name', @with_copy = 0

How to quickly determine what tables are being stretched?

Well some modifications took place to system view like sys.databases and sys.tables. Then if you need to monitor the databases that are stretched the following t-sql can be executed:

select name
from sys.databases
where is_remote_data_archive_enabled = 1

what about the tables? in order to determine what tables are getting stretched, the following query becomes very handy:

select object_id,
name
, is_remote_data_archive_enabled
from sys.tables
where is_remote_data_archive_enabled = 1

Conclusions

  1. It is a great way to decrease the recovery time of a very large database in case of restore from backups.
  2. It is a great way to decrease storage billing for historical data, since the data is in azure and just what is getting used is what is getting bill.
  3. Since it is the first release of the technology, it comes with a lot of restrictions like:
    1. No Updates allowed (up to RC3)
    2. No Deletes Allowed
    3. Etc, the list is long.
  4. Set up a stage or pre-production environment is complicated since there is not a way to restore the database in stage and link it to a different Azure DB.
  5. Alter on the stretched tables are not allowed, so in case of modifications the data has to be migrated to a new structure.

If you want me to take a look at your server and its settings, or if your server is facing any issue we can Fix Your SQL Server.

Reference: Pinal Dave (http://blog.sqlauthority.com)

First appeared on SQL SERVER 2016 – How to Use SQL Server 2016 – Stretch Database – Notes from the Field #127

SQL SERVER – FIX – Linked Server Error 7399 Invalid authorization specification

$
0
0

I have personally seen when people use Linked Server there are a number of issues from authentication to performance. These issues are part of working with something that has so many variations and permutations of actually going wrong. Many a times I suggest people to keep away from it as much as possible. But it cannot happen all the times and there are code blocks in their application that relies on this as a requirement.

This is one of the common error I see in various forums. When someone is new to SQL Server and tried to create a linked server, he/she would just give server name and choose SQL Server as server type and hit OK. But SSMS would provide below error

SQL SERVER - FIX – Linked Server Error 7399 Invalid authorization specification linked-error-01

TITLE: Microsoft SQL Server Management Studio
——————————
The linked server has been created but failed a connection test. Do you want to keep the linked server?
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
The OLE DB provider “SQLNCLI11” for linked server “BIGPINAL” reported an error. Authentication failed.
Cannot initialize the data source object of OLE DB provider “SQLNCLI11” for linked server “BIGPINAL”.
OLE DB provider “SQLNCLI11” for linked server “BIGPINAL” returned message “Invalid authorization specification”. (Microsoft SQL Server, Error: 7399)
——————————
BUTTONS:
&Yes
&No
——————————

Above message has two messages

  1. A Question: The linked server has been created but failed a connection test. Do you want to keep the it?
  2. An Error: Microsoft SQL Server, Error: 7399 – The OLE DB provider “%ls” for linked server “%ls” reported an error. %ls

We can click Yes and linked server would be created but it won’t work. Once we click on Test Connection as shown below – we would get same error what we got during creation.

To fix this problem, we need to understand little about connectivity and authentication. Whenever we connect to SQL, there are two ways

  1. SQL Authentication: To use this, we need to provide login name and password while connecting to SQL Server. These account are stored within SQL Server.
  2. Windows Authentication: While using Windows operating system, we can use logged in account to SQL and it would allow us to connect to SQL Server without providing password because we have already logged into operating system and have been authenticated by Windows.

When the linked server is created, the default values under security is “Be made without using a security context” – this is the cause of the problem.

Solution: Choose one of the two from below highlighted.

SQL SERVER - FIX – Linked Server Error 7399 Invalid authorization specification linked-error-02

Have you seen this earlier? How would you provide windows account here? What are your opinion? Do let me know via comments below.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – FIX – Linked Server Error 7399 Invalid authorization specification

SQL SERVER – FIX – Agent XPs Component is Turned Off as Part of the Security Configuration for this Server

$
0
0

One of my clients has installed a new instance of SQL Server and then wanted to create maintenance plan. They were complaining about getting some error and we’re looking forward for my help to solve the same. As soon as he did right click on a Maintenance Plan under “Management” node and selected “New Maintenance Plan Wizard” using SQL Server Management Studio as shown below. Let us learn how to fix Agent XPs Component is Turned Off as Part of the Security Configuration for this Server error.

SQL SERVER - FIX - Agent XPs Component is Turned Off as Part of the Security Configuration for this Server MP-Error-01

It gave below error.

SQL SERVER - FIX - Agent XPs Component is Turned Off as Part of the Security Configuration for this Server MP-Error-02

Here is the text of the message.

TITLE: Microsoft SQL Server Management Studio
——————————
Cannot show requested dialog.
——————————
ADDITIONAL INFORMATION:
Unable to execute requested command.
——————————
‘Agent XPs’ component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘Agent XPs’ by using sp_configure. For more information about enabling ‘Agent XPs’, see “Surface Area Configuration” in SQL Server Books Online. (Microsoft.SqlServer.Management.MaintenancePlanWizard)
——————————
BUTTONS:
OK
——————————

There are two ways to fix the problem.

  1. Start SQL Server Agent Service.
    SQL SERVER - FIX - Agent XPs Component is Turned Off as Part of the Security Configuration for this Server MP-Error-03 You can also start SQL Server Agent service by using the SQL Server Configuration Manager on start>run>services.msc applet.
  1. Enable Agent XPs under sp_configure using below command in SQL Server Management Studio query window.
SP_CONFIGURE 'SHOW ADVANCE',1
GO
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'AGENT XPs',1
GO
RECONFIGURE WITH OVERRIDE
GO

Here is the output

Configuration option ‘show advanced options’ changed from 0 to 1. Run the RECONFIGURE statement to install.
Configuration option ‘Agent XPs’ changed from 0 to 1. Run the RECONFIGURE statement to install.

Once any of the above is followed, you should be able to create maintenance plan. You might ask, why someone would need use # 2 instead of # 1. It is important to remember that if you want to create maintenance plan without starting SQL Agent service (as it might cause jobs to run which are scheduled) then you would choose option 2. A very uncommon but possible scenario.

If you are not able to start SQL Server Agent service, then you may want to look at below blog

SQL SERVER – Unable to start SQL Server Agent – Failed to Initialize SQL Agent log

There might be some other error but SQLAgent.out and event log is a good place to start troubleshooting the issue. Do let me know if you encountered this error ever in your environments. Do leave a comment.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – FIX – Agent XPs Component is Turned Off as Part of the Security Configuration for this Server

SQL SERVER – Maintenance Plan Folder Missing Under Management in SQL Server Management Studio

$
0
0

The best part of learning is by the error messages that each one of you send me over the years. These are a great source of experimentation and a lot of searching to get to the appropriate error resolution. I take this an opportunity to connect with various people and look for active solutions one has achieved from their experience. One of my readers sent an email as shown below about Maintenance Plan Folder Missing Under Management in SQL Server Management Studio:

Hi Pinal,
I have installed SQL Server 2016 for my 3rd party software. Since it’s a financial data, I wanted to make sure that we have backups taken regularly. I read on internet and found that I can created maintenance plan to take backup on scheduled basis. I was surprised to see that I am not having folder called Maintenance Plan. I have tried to repair of management studio and SQL Serve engine, but none of them helped.

SQL SERVER - Maintenance Plan Folder Missing Under Management in SQL Server Management Studio mp-missing-01

Do you have any pointers to fix this weird issue? As you must have imagined that I am not a SQL DBA but a DBA by project demand, so please be generous.

Thanks in advance,
<One of blog Reader>

In my reply to his email I asked for complete snapshot of object explorer and output of select @@version output. Since it was SQL Server 2016, I thought that there is something new. While I was waiting, I tried to think the cause and created a public account in my lab’s SQL Server. But, there is what I saw when I logged it with that account, which was not a Sysadmin.

SQL SERVER - Maintenance Plan Folder Missing Under Management in SQL Server Management Studio mp-missing-02

Yay!! I don’t see SSMS but this is not exactly matching with reader’s SSMS. When I got his reply, things were crystal clear. Here is the output he shared with me for “select @@version”

Microsoft SQL Server 2016 (RTM) – 13.0.1601.5 (X64)
Apr 29 2016 23:23:58
Copyright (c) Microsoft Corporation
Express Edition (64-bit) on Windows Server 2012 R2 Datacenter 6.3 (Build 9600: ) (Hypervisor)

This was an EXPRESS edition of SQL Server. Since there is no SQL Agent with SQL Server, there is no point of scheduling and hence no maintenance plan folder.

To summarize, there could be 2 reasons which I could find.

  1. Logged in account not having sysadmin permissions. Below query would return 0.
SELECT IS_SRVROLEMEMBER('sysadmin')
  1. Express edition of SQL Server. Below query would say express edition
SELECT SERVERPROPERTY('Edition')

Do you know any other reason? Please share via comments. I am sure this will be a learning for me too about SQL Server Management Studio.

Reference: Pinal Dave (http://blog.sqlauthority.com)

First appeared on SQL SERVER – Maintenance Plan Folder Missing Under Management in SQL Server Management Studio

SQL SERVER to Oracle Numeric Datatype Mapping

$
0
0

Getting into a consulting business has its own set of challenges that I cherish big time. Recently I was consulted by a product team that had some of the best guys in the market. I was surprised why they might need my services. But I had an open mind to go through what they were doing. They were migrating their current application that was running fine in Oracle to SQL Server. My first thought was – “Wow”. Currently enterprises and organizations do think of SQL Server as a viable, competent alternative when it comes to database choice.

Now this was obviously not the problem. They had some application logic and were actually doing the same code of ETL to push data from Oracle to SQL Server. It was all fine, but suddenly when there was considerable load they were seeing some performance problems. I was not sure why something behaves so differently when compared to Oracle.

I started the profiler and I was waiting to see what were some of the plans that were getting generated. I was surprised to see tons of implicit converts happening in the system when the profiler was working at the backend. On further investigation the Application team said they used a number of options working inside Oracle like Number (x) datatypes and were using a safe bet of Int / BigInt when working with SQL Server. Worst was, the application that was sending the generic code had no clue of this.

This set me into this journey of educating the migration team on how important it is to send the appropriate data when working inside SQL Server. These might not be simple and I don’t recollect writing about these. See below a pseudo mapping of datatypes that one needs to use when doing such migration exercise.

SQL SERVER to Oracle Numeric Datatype Mapping Oracle-Numeric-01-800x820

It is important to take the time to do profiling on the data in your source database to know what you are moving over. People often use data types that are too big and unnecessary for the application – this needs to be avoided. For example, if the application only uses ‘Int’ then use ‘Int’. Again, this is an opportunity to improve the architecture and implementation as part of a migration.

Note: that “Blobs” can be difficult to move over. SSIS is the best tool to use in this case.

As I wrap up, I would love to hear about how you used or mapped datatypes when migrating or working with Oracle and SQL Server? Do share your tips and tricks as we can learn together.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER to Oracle Numeric Datatype Mapping

SQL SERVER – Unable to Start SQL Agent – SQL Server Agent Terminated (Normally)

$
0
0

Along with performance issues, I also provide consultancy in other break-fix issues like service not starting etc. These are not run of the mill, but on specific cases only. I always suggest my clients to search on my blog first and then contact me if needed. This is a great way to scale and make people empowered when it comes to solving some of the trivial issues that they might have encountered for SQL Server Agent.

Here is the one of the situation where SQL Agent was not able to start in Clustered environment. When we try to start from the SERVICES.msc, it is going to run the state and then in 30 Sec or so stops automatically. As usual, I have asked for SQL Agent Log which is at the same location as SQL Server ERRORLOG.

Where is ERRORLOG? Various Ways to Find ERRORLOG Location

Here is the content of SQLAgent.OUT file.

2016-05-07 06:44:03 – ? [100] Microsoft SQLServerAgent version 11.0.2100.60 (X64 unicode retail build) : Process ID 9252
2016-05-07 06:44:03 – ? [495] The SQL Server Agent startup service account is Super\SVC.
2016-05-07 06:44:34 – ! [150] SQL Server does not accept the connection (error: 53). Waiting for Sql Server to allow connections. Operation attempted was: Verify Connection On Start.
2016-05-07 06:44:34 – ! [000] Unable to connect to server ‘(local)’; SQLServerAgent cannot start
2016-05-07 06:44:40 – ! [298] SQLServer Error: 53, Named Pipes Provider: Could not open a connection to SQL Server [53]. [SQLSTATE 08001] 2016-05-07 06:44:40 – ! [165] ODBC Error: 0, Login timeout expired [SQLSTATE HYT00] 2016-05-07 06:44:40 – ! [298] SQLServer Error: 53, A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [SQLSTATE 08001] 2016-05-07 06:44:40 – ! [382] Logon to server ‘(local)’ failed (DisableAgentXPs)
2016-05-07 06:44:40 – ? [098] SQLServerAgent terminated (normally)

Based on above, it is clear that SQL Server Agent is not able to connect to SQL Server with below error.

A network-related or instance-specific error has occurred while establishing a connection to SQL Server. The server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information, see SQL Server Books Online.

This is a very generic error which can happen due to many reasons. One of my famous blog for this error is below

FIX : ERROR : (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

Solution / Fix:

For this client, I found that it is a SQL default instance running with Non-default port (port other than 1433). So I started SQL Server Browser service on both the nodes, but still there was no luck. Later found that this was due to name resolution issue with the DNS so to fix the issue, we added the TCP alias on both nodes and that fixed the issue.

SQL SERVER - Unable to Start SQL Agent - SQL Server Agent Terminated (Normally) alias-01

SQLCLUSTER – SQL Server Virtual Server Name
Port – SQL listening port
Protocol – TCP/IP
Server – IP Address for SQL Clustered instance.

Did you face similar issue is clustered about resource not coming online? When did it happen for you and what did you do then? Please feel free to share your experience via the comments.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Unable to Start SQL Agent – SQL Server Agent Terminated (Normally)

SQL SERVER 2016 – How to Import New Sample Database WideWorldImporters

$
0
0

Few days back I wrote blog about SQL Server 2016 Developer Edition free download. If you didn’t get a chance to have a look, here is the link. Download SQL SERVER 2016 Developer Version for FREE. Let us learn about how to install Sample Database WideWorldImports.

In that blog, I also said that, here is a new sample database called WideWorldImporters. This database is a replacement of old sample database called AdventureWorks (Engine version) and AdventureWorksDW (Data Warehouse version)

SQL SERVER 2016 - How to Import New Sample Database WideWorldImporters WideWorldImporters-800x259

Here is the link to download latest version of the sample database Wide World Importers sample database v1.0

Once you go to the page, you would find various files to download. Here is the quick list about few of them which you would be using.

File Name Purpose
WideWorldImporters-Full.bak Use this if you have Enterprise/Developer/Enterprise Evaluation Edition
WideWorldImporters-Standard.bak Use this if you have Standard Edition
WideWorldImportersDW-Full.bak Use this if you have Enterprise/Developer/Enterprise Evaluation Edition
WideWorldImportersDW-Standard.bak Use this if you have Standard Edition

The reason there are two for the standard edition separately is because there are many features which are not available in standard edition. If you try to “full” on the standard edition, you will not be able to open the database.

Here is the command which you can use to restore the database. Note that I have created a folder called C:\WideWorldImporters-Full. I have kept a backup. Please change based on your server configuration.

Install Sample Database WideWorldImports

USE [master]
RESTORE DATABASE [WideWorldImporters] FROM  
DISK = N'C:\WideWorldImporters-Full\WideWorldImporters-Full.bak' WITH
MOVE N'WWI_Primary' TO N'C:\WideWorldImporters-Full\WideWorldImporters.mdf',  
MOVE N'WWI_UserData' TO N'C:\WideWorldImporters-Full\WideWorldImporters_UserData.ndf',  
MOVE N'WWI_Log' TO N'C:\WideWorldImporters-Full\WideWorldImporters.ldf',  
MOVE N'WWI_InMemory_Data_1' 
TO N'C:\WideWorldImporters-Full\WideWorldImporters_InMemory_Data_1'
GO

Once restore is done, this is what you should see

SQL SERVER 2016 - How to Import New Sample Database WideWorldImporters WWI-01

Do you see a table with clock icon? What is that feature called? These are great ways of learning the new capabilities via the sample database.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER 2016 – How to Import New Sample Database WideWorldImporters


SQL SERVER – Installation Error – The wrong diskette is in the drive. Insert (Volume Serial Number: ) into drive.

$
0
0

The world of working with errors always gets the better of me. It is a wonderful way to understand why SQL Server behaves in a certain way and most importantly, it helps me solve some of the problems people face on a day-to-day basis. As you might know that along with performance consultancy, I also reply to any personal email asking for help. This blog is a result of one such interaction where the client was facing an error while installing Service Pack 4 for SQL Server 2008 in a clustered environment. Let us learn about Installation Error.

SQL SERVER - Installation Error - The wrong diskette is in the drive. Insert (Volume Serial Number: ) into drive. insert-disk-01

I always ask for setup logs and start from there. One of my old blog talks about location of setup files.

SQL SERVER – Installation Log Summary File Location – 2012 – 2008 R2

I looked into %programfiles%\MicrosoftSQL Server\110\Setup Bootstrap\Log\ and found folder corresponding to date-time of installation. Immediately open Summary.txt file and found errors.

Overall summary:
Final result: The patch installer has failed to update the following instance: MSSQLSERVER. To determine the reason for failure, review the log files.
Exit code (Decimal): -568706566
Exit facility code: 1562
Exit error code: 14842
Exit message: The patch installer has failed to update the following instance: MSSQLSERVER. To determine the reason for failure, review the log files.
Start time: 2016-05-17 03:18:32
End time: 2016-05-17 03:23:33
Requested action: Patch

Instance MSSQLSERVER overall summary:
Final result: The patch installer has failed to update the shared features. To determine the reason for failure, review the log files.
Exit code (Decimal): -568706566
Exit facility code: 1562
Exit error code: 14842
Exit message: The wrong diskette is in the drive. Insert (Volume Serial Number: ) into drive . (Exception from HRESULT: 0x80070022)
Start time: 2016-05-17 03:19:32
End time: 2016-05-17 03:22:33
Requested action: Patch

As per the error it suggested me to review the log file. I looked further and opened Detail.txt for this instance.

Exception summary:
The following is an exception stack listing the exceptions in outermost to innermost order
Inner exceptions are being indented

Exception type: System.Runtime.InteropServices.COMException
Message:
The wrong diskette is in the drive. Insert (Volume Serial Number: ) into drive . (Exception from HRESULT: 0x80070022)
Data:
DisableWatson = true
Stack:
at Microsoft.SqlServer.Interop.MSClusterLib.ISClusResource.get_Disk()
at Microsoft.SqlServer.Configuration.Cluster.ClusterPhysicalDisk.get_Partitions()
at Microsoft.SqlServer.Configuration.ClusterConfiguration.ClusterDiskPublicConfigObject.IsPathOnSharedDisk(String path)
at Microsoft.SqlServer.Configuration.SetupExtension.SlpInputSettings.ValidateNotOnSharedDisk(ValidationState vs, String directoryName, String bindingKey, String errorMessage)
at Microsoft.SqlServer.Configuration.SetupExtension.SlpInputSettings.Validate_InstallSharedDir(ValidationState vs)
at Microsoft.SqlServer.Configuration.SetupExtension.SlpInputSettings.ValidateSettings()
at Microsoft.SqlServer.Configuration.SetupExtension.ValidateFeatureSettingsAction.ExecuteAction(String actionId)
at Microsoft.SqlServer.Chainer.Infrastructure.Action.Execute(String actionId, TextWriter errorStream)
at Microsoft.SqlServer.Setup.Chainer.Workflow.ActionInvocation.InvokeAction(WorkflowObject metabase, TextWriter statusStream)
at Microsoft.SqlServer.Setup.Chainer.Workflow.PendingActions.InvokeActions(WorkflowObject metaDb, TextWriter loggingStream

Here are the major things in above stack, which any SQL DBA can understand.

Interop.MSClusterLib.ISClusResource.get_Disk()
ClusterPhysicalDisk.get_Partitions()
ClusterDiskPublicConfigObject.IsPathOnSharedDisk(String path)
ValidateNotOnSharedDisk
Validate_InstallSharedDir

From the stack it is clear that they have issues with clustered disk. So, I have asked them to contact their hardware team and they fixed the issue. Once it was fixed, Service pack installation went fine.

I believe, it not always possible to provide solution but a guideline is also sufficient. Hope this helps you and let me know via comments if you encountered this Installation Error.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Installation Error – The wrong diskette is in the drive. Insert (Volume Serial Number: ) into drive.

SQL SERVER – Event ID 7000 – The service did not start due to a logon failure

$
0
0

Many times I feel that I have so many blogs that I must have covered all common possible error related to usage of SQL Server. But there are few easy ones which I missed. And thanks to those who take time in sending them to me that it makes a great reminder to what I have missed till date. This blog is from one of such logon failure errors that came from a DBA from one of my consulting engagements. Since the error was simple enough, I thought to respond over mail to solve the problem.

After restarting my box, SQL Service didn’t start even though it was set to start automatically. As usual, I started looking around for error messages and fond below in the event log.

Log Name:      System
Source:        Service Control Manager
Date:          13-May-16 5:29:37 AM
Event ID:      7000
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      BIGPINAL
Description:
The SQL Server (SQL2014) service failed to start due to the following error:
The service did not start due to a logon failure.

I know how to fix the problem, but I found that I didn’t have a blog on this error. So here are the steps.

  1. Get the correct password of the account which is used to run the service. Take help from your domain administrators. If you decide to reset the password, keep in mind that this account might be used at other SQL Instance and other applications also.
  2. Use SQL Server Configuration Manager and choose the service which is not able to start.
  3. Right Click and go to Properties.

 SQL SERVER - Event ID 7000 - The service did not start due to a logon failure logon-failure-01

  1. Provide correct password on the Log On tab as shown below.

 SQL SERVER - Event ID 7000 - The service did not start due to a logon failure logon-failure-02

Once the correct password is provided, you should be able to start SQL Service without any problem. Have you ever encountered this error ever in your environments? Do let me know about what you did to solve the same.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Event ID 7000 – The service did not start due to a logon failure

SQL SERVER – FIX – Linked Server Error 7416 – Access to the remote server is denied because no login-mapping exists

$
0
0

Last time I wrote a blog about linked server creation issue. As I said, these are one of the most common issues. But as soon as such blogs get released, I get a number of requests around them immediately. Here is the blog post which is discussing about the linked server error.

SQL SERVER – FIX – Linked Server Error 7399 Invalid authorization specification

After reading that one of the readers contacted me and told that he is getting below error.

SQL SERVER - FIX - Linked Server Error 7416 - Access to the remote server is denied because no login-mapping exists err-7416-01

On first look, I thought this was similar to what was published earlier. But things can surely turn out to be different. Since I had recently blogged about it, I thought to investigate this. To understand more, I looked at the error message in detail. It looks like:

TITLE: Microsoft SQL Server Management Studio
——————————
The linked server has been created but failed a connection test. Do you want to keep the linked server?
——————————
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
——————————
Access to the remote server is denied because no login-mapping exists. (Microsoft SQL Server, Error: 7416)
——————————

I played around with the linked server settings on the PC just to realize – I was able to reproduce the error by choosing 1st option in security tab. This was simpler than what I thought.

SQL SERVER - FIX - Linked Server Error 7416 - Access to the remote server is denied because no login-mapping exists err-7416-02

So, I asked him to use either option 2 or option 3. After using right option, the error message disappeared.

Do you remember seeing any such linked server error? Can you share your experience to what happened here this time? Leave a comment as we can learn from each other.

Reference: Pinal Dave (http://blog.sqlauthority.com)

First appeared on SQL SERVER – FIX – Linked Server Error 7416 – Access to the remote server is denied because no login-mapping exists

SQL SERVER – SQL Profiler vs Extended Events

$
0
0

To tell you the truth, I didn’t know how to start this article about SQL Profiler vs Extended Events. After all, I decided to take mind off things and to watch a movie. The movie was Iron Man 2. In addition to the brilliant performance of Robert Downie Jr., one phrase stuck in my mind and immediately inspired my writing.

“Don’t get so attached to things, learn to let go.”
~ Iron Man 2 (Robert Downie Jr)

It seemed to me, that this phrase reflects status quo when it comes to selection of a query profiling solution. What would you choose: the old reliable SQL Profiler or something new? My personal choice is Extended Events. Why?

Try running SQL Profiler…or even several instances of it:) on the overloaded production server. And leave it alone for five-ten minutes.

Then, try executing a query to see what delays occurred during the work of SQL Trace:

SELECT
      wait_type
    , wait_time = wait_time_ms / 1000.
    , wait_resource = (wait_time_ms - signal_wait_time_ms) / 1000.
    , wait_signal = signal_wait_time_ms / 1000.
    , waiting_tasks_count
FROM sys.dm_os_wait_stats
WHERE [wait_type] IN (
        'TRACEWRITE', 'OLEDB', 'SQLTRACE_LOCK',
        'SQLTRACE_FILE_BUFFER', 'SQLTRACE_FILE_WRITE_IO_COMPLETION'
    )

It is important to realize that if the trace filter is not set, SQL Profiler may significantly load your server. That’s why the new tracing mechanisms, called Extended Events were included into SQL Server 2008.  They require less server resources and allow to trace more events.

To deal with Extended Events, we should go back to SQL Profiler and comprehend its work.

First, a new SQL trace is created, and information to be traced is noted:

DECLARE @id INT

EXEC sys.sp_trace_create @id OUTPUT, 2, N'D:\MyTrace'

EXEC sys.sp_trace_setevent @id, 10, 1, 1
EXEC sys.sp_trace_setevent @id, 10, 13, 1
EXEC sys.sp_trace_setevent @id, 10, 15, 1
EXEC sys.sp_trace_setevent @id, 12, 1, 1
EXEC sys.sp_trace_setevent @id, 12, 10, 1
EXEC sys.sp_trace_setevent @id, 12, 13, 1
EXEC sys.sp_trace_setevent @id, 12, 15, 1

To understand where these magical digits come from, you need to execute the following query:

SELECT
      EventCategory = c.Name
    , EventClass = e.Name
    , EventColumn = t.Name
    , EventID = e.trace_event_id
    , ColumnID = b.trace_column_id
FROM sys.trace_categories c
JOIN sys.trace_events e ON e.category_id = c.category_id
JOIN sys.trace_event_bindings b ON b.trace_event_id = e.trace_event_id
JOIN sys.trace_columns t ON t.trace_column_id = b.trace_column_id
--WHERE b.trace_event_id IN (10, 12)

Then, we can filter information that will be traced. For instance, let’s ignore queries sent by SQL Profiler:

EXEC sys.sp_trace_setfilter @id, 10, 1, 7, N'SQL Profiler'

After all settings, we can run the trace:

EXEC sys.sp_trace_setstatus @id, 1

To enable SQL Profiler to output trace results, we need to execute a query similar to the following:

SELECT SPID, TextData, ApplicationName, Duration = Duration / 1000, EndTime
FROM (
    SELECT TOP(1) [path]
    FROM sys.traces
    WHERE [path] LIKE N'D:\MyTrace%'
) t
CROSS APPLY sys.fn_trace_gettable(t.[path], DEFAULT)

When tracing is no longer required, we can stop and delete it:

DECLARE @id INT = (
    SELECT TOP(1) id
    FROM sys.traces
    WHERE [path] LIKE N'D:\MyTrace%'
)

EXEC sys.sp_trace_setstatus @id, 0
EXEC sys.sp_trace_setstatus @id, 2

The same principle is used in Extended Events. First, the event should be created:

CREATE EVENT SESSION XEvent ON SERVER
ADD EVENT sqlserver.sql_statement_completed
(
    ACTION (
        sqlserver.database_id,
        sqlserver.session_id,
        sqlserver.username,
        sqlserver.client_hostname,
        sqlserver.sql_text,
        sqlserver.tsql_stack
    )
    --WHERE sqlserver.sql_statement_completed.cpu > 100
    --    OR sqlserver.sql_statement_completed.duration > 100
)
ADD TARGET package0.asynchronous_file_target
(
    SET FILENAME = N'D:\XEvent.xet',
    METADATAFILE = 'D:\XEvent.xem'
)

To learn the event list, you can execute the following query:

SELECT
    package_name = p.name,
    event_name = o.name
FROM sys.dm_xe_packages p
JOIN sys.dm_xe_objects o ON p.[guid] = o.package_guid
WHERE o.object_type = 'event'

After creation, we need to run the event:

ALTER EVENT SESSION XEvent ON SERVER STATE = START

In the general case, you can get data from the trace with the following query:

SELECT
      duration = x.value('(event/data[@name="duration"])[1]', 'INT') / 1000
    , cpu_time = x.value('(event/data[@name="cpu_time"])[1]', 'INT') / 1000
    , logical_reads = x.value('(event/data[@name="logical_reads"])[1]', 'INT')
    , writes = x.value('(event/data[@name="writes"])[1]', 'INT')
    , row_count = x.value('(event/data[@name="row_count"])[1]', 'INT')
    ,  = x.value('(event/data[@name="statement"])[1]', 'NVARCHAR(MAX)')
    , [db_name] = DB_NAME(x.value('(event/action[@name="database_id"])[1]', 'INT'))
    , end_time = x.value('(event/@timestamp)[1]', 'DATETIME')
FROM (
    SELECT x = CAST(event_data AS XML).query('.')
    FROM sys.fn_xe_file_target_read_file('D:\XEvent*.xet','D:\XEvent*.xem', NULL, NULL)
) t

When the trace is no longer required, you can turn it off temporarily:

ALTER EVENT SESSION XEvent ON SERVER STATE = STOP

Or delete it:

IF EXISTS(
    SELECT *
    FROM sys.server_event_sessions
    WHERE name='XEvent'
) DROP EVENT SESSION XEvent ON SERVER

As I wrote earlier, Extended Events offer more monitoring options. If we compare the quantity of events (e.g. in SQL Server 2014) that can be traced with xEvents, SQL Trace is not a patch on Extended Events:

SELECT xevents = COUNT_BIG(*)
FROM sys.dm_xe_objects o
WHERE o.object_type = 'event'

SELECT sql_trace = COUNT_BIG(*)
FROM sys.trace_events e

xevents
————
874

sql_trace
————
180

On this point, we could draw a line and forget about SQL Profiler. But there is one nuance.

The work with xEvents in SSMS 2012…2016 is implemented in a new learning if you are a beginner. And if SSMS 2008 is used, the stalemate situation occurs – this version of SSMS does not support Extended Events.

I think that this is the main reason why very few people use Extended Events. Some are scared by its ascetic GUI. But admit that this is not the reason to abandon this technology… moreover, there is a great tool that drew my attention long ago.

dbForge Event Profiler for SQL Server  is a free and the more functional counterpart to SQL Server Profiler that can work with xEvents. What do I like in it? Well, in the first place it is syntax highlighting, which we will hardly ever see in Server Profiler:

SQL SERVER - SQL Profiler vs Extended Events devext1

Secondly, the tool allows to filter and sort the grid with tracing results:

SQL SERVER - SQL Profiler vs Extended Events devext2

The next advantage is lots of predefined templates for query profiling:

SQL SERVER - SQL Profiler vs Extended Events devext3

dbForge Event Profiler has one more feature that does not directly correlate with xEvents.

I wonder, have you ever faced a situation when a large SQL file must be executed, but SSMS rejected to open it or crashed because of OutOfMemory? If you have, I have a solution for your problems – with dbForge Event Profiler, you can execute large scripts without opening them in the editor:

SQL SERVER - SQL Profiler vs Extended Events devext4

All you have to do is to specify the database for the application of all changes:

SQL SERVER - SQL Profiler vs Extended Events devext5

And to click Execute.

It’s time to sum everything up. The obvious pros of Extended Events are:

  1. xEvents requires less server resources and works faster
  2. You can trace more server events
  3. Flexible settings mechanism

The only con I can point out is inconvenience of working with xEvents and SSMS. But for me it is not a reason to stay an obedient aficionado of SQL Profiler. I can definitely recommend the free tool dbForge Event Profiler and open a brave new world of Extended Events to yourself.

Reference: Pinal Dave (http://blog.sqlauthority.com)

First appeared on SQL SERVER – SQL Profiler vs Extended Events

SQL SERVER – Fix Error – 948 A downgrade path is not supported. The database cannot be opened because it is version.

$
0
0

These past weeks the number of errors I have been getting when attaching a database has been far too many. But the best part of this learning experience is that I get to write about them one after another. There are no right or wrong answers sometimes, but am learning every time. Here is an error which is related to a downgrade path not supported.

Fix Error 948 – A Downgrade path is not supported

Here is the error I received while I was trying to attach database using below command:

USE [master]
GO
CREATE DATABASE [SQLAuthority] ON 
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\DATA\SQLAuthority.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL13.SQL2016\MSSQL\DATA\SQLAuthority_log.ldf' )
 FOR ATTACH
GO

SQL SERVER - Fix Error - 948 A downgrade path is not supported. The database cannot be opened because it is version. down-attach-error-01

Error message:

Msg 1813, Level 16, State 2, Line 3
Could not open new database ‘SQLAuthority’. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 3
The database ‘SQLAuthority’ cannot be opened because it is version 852. This server supports version 782 and earlier. A downgrade path is not supported.

The second part of the message was strange and was the first time I was seeing. I found a command on the internet to read MDF file version:

DBCC CHECKPRIMARYFILE('C:\Program Files\Microsoft SQL
Server\MSSQL13.SQL2016\MSSQL\DATA\SQLAuthority.mdf',2)

SQL SERVER - Fix Error - 948 A downgrade path is not supported. The database cannot be opened because it is version. down-attach-error-02

So, we know that version is 802 which is for SQL Server 2016. When I ran select @@version on my server I found that I was trying to attach it to lower versions of SQL.

In short, this error is expected when we try to attach file from higher version of SQL to lower version of SQL. We cannot attach/detach or backup/restore a database from a newer version of SQL Server down to an older version – the internal file structures are just too different to support backwards compatibility.

Here is what I was able to find on the internet.

SQL Server Version Internal Database Version
SQL Server 2016 852
SQL Server 2014 782
SQL Server 2012 706
SQL Server 2008 R2 660/661
SQL Server 2008 655
SQL Server 2005 611/612
SQL Server 2000 539
SQL Server 7 515

Do you know the steps to move to older version? What have you done before for such errors? Do feel free to share with all via the comments section below.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

First appeared on SQL SERVER – Fix Error – 948 A downgrade path is not supported. The database cannot be opened because it is version.

Viewing all 599 articles
Browse latest View live