Wednesday, 28 December 2016

SQL Server : SQL Server 2016 New Features

SQL Server 2016 New Features

1:-  Always Encrypted

Starting off, we have always encrypted. This feature enables a client side encryption of table data. This is similar to column encryption, but unlike column encryption, the data type does not need to be varbinary. 

This feature requires a driver on the client applications to communicate with the database. Encryption occurs at the client side, so the data is not plain text during transmission. 

Another difference from column encryption (as a SQL only technology) is that the encryption key may either be deterministic or randomized. The benefit of deterministic is that it allows for the indexing of column data so that performance of queries that need to filter on the column are more efficient. 

2:-  Row Level Security

Row Level Security allows tables to be configures where some users may work with only a subset of rows in the table. This function requires setup on the DB side as well as coding requirements on the developer side. Working with this feature requires setting up inline table functions and security policies on tables that govern the filtering/blocking at the row level. 

Some of the issues that may arise from this feature is inconsistent application functionality, since with the security policies set up, it’s possible to create an instance where a user may update/insert a record, but then not be able to view it. 


3:- Dynamic Data Masking

This, as the name suggests, allows for data to be stored normally, but only certain users may see the information unmasked. Masking is performed as part of a table’s DDL; assigning masking at a column level. 

There are new permissions to allow granular rights of unmasking to certain user groups. However, dbo always have unmasking rights. All queries accessing masked columns are automatically masked/unmasked depending of the permission of the user making the query. 

Masking does not alter the underlying data, therefore, adding masking to columns is a table metadata change. 


4:-  Availability Groups

A few more improvements were made in Availability Groups. Automatic failover may now be performed over a set of 3 nodes, instead of 2. As well log transport to synchronize between the primary and secondary replica(s) was streamlined. In addition, build in load balancing of the replicas is possible. (2014 and earlier, all traffic was directed to one node unless it was unavailable, or 3rd party products needed to be used).

5 :-  TempDB Enchancements

On installation tempdb will have created the recommended number of files (1 per logical processor up to 8). This can still be modified on installation to something besides the default. As well, trace flags 1117 and 1118 have been eliminated as their functionality has been built into tempdb. (1117 was uniform data file growth, 1118 was full extent allocation)

6 :-  Query Store

One of the best new features, from a DBA’s perspective. Query Store is a per database implemented item. It is meant to greatly increase the ease of finding performance issues and troubleshooting. 

The query store has two components, a plan store that persists the execution plans, and a run-time stats store, that persists the stats surrounding query execution (CPU, I/O, memory etc). 

7:- R integration

R is a programming language widely used by data scientists for advanced analytics. SQL Server R Services is a result of a Microsoft acquisition in 2015. For SQL 2016, R services have been integrated into the SQL Server platform. R code may be executed directory in a sql database. This adds to te workload of the server, but allows to greater security and performance because data movement is minimized. 

8:- SSRS 

There are a number of improvement in 2016 (compared with almost no change in 2014). 
Mobile reports are now supported with the integration of another Microsoft acquisition. Mobile reports and standard reports may be viewed through the same web portal interface of the report server. 

As well, enhancements have been created to make administering ownership and subscriptions easier. 

9 :-  Polybase

Polybase is s transparent access layer that facilitates connectivity between SQL and Hadoop data sources. It’s purpose is to merge big data into SQL platforms. This integrations means you can execute T-SQL queries against this platform without knowing Map/Reduce, Hive or any other Hadoop related tools. 

Hope it will be helpful. I'll try to write more on these features in detail in coming days. 

Thanks



Thursday, 22 December 2016

SSRS : Query execution failed for dataset (rsErrorExecutingCommand)

SSRS : Query execution failed for dataset (rsErrorExecutingCommand) 

An error has occurred during report processing. (rsProcessingAborted)
Query execution failed for dataset 'dataset1'. (rsErrorExecutingCommand)
For more information about this error navigate to the report server on the local server machine, or enable remote errors 

To find out the exact error:

1. Navigate to E:\Program files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\LogFiles\ReportServerService__12_22_2016_00_04_44.log

2. Located the following error

 Info: 

Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Query execution failed for dataset 'dataset1'. ---> System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'get_report_data', database 'Test123', schema 'dbo'.

Resolution:

Granted the execute permisison to account which was used to create data source.

grant execute on [get_report_data] to [ReportID]

Retry accessing the report. You should not see the error anymore and report should be running fine.

Thanks

Thursday, 28 April 2016

For SQL Server DBAs :: Frequently used System Administrator command line shortcuts to popular MMCs

For SQL Server DBAs :: Frequently used System Administrator command line shortcuts to popular MMCs



Simply get to a run command (Start>Run) or a  command prompt (Start>Run>CMD [enter])


Local Security Settings Manager : secpol.msc
Local Users and Groups Manager : lusrmgr.msc
Services Management : services.msc
Shared Folders : fsmgmt.msc
Teminal Services RDP : MSTSC
Teminal Services RDP to Console : mstsc /v:[server] /console
Windows Mangement Instumentation : wmimgmt.msc
Disk Manager : diskmgmt.msc
Event Viewer : eventvwr.msc
Computer Management : compmgmt.msc

Thursday, 16 July 2015

SQL Server: How to use NamedPipe Protocol to establish connection

Error:-

 (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)

To resolve this issue , we can create alias on client server using TCP/IP protocol.

But story was different here, There was a situation when an application was unable/couldn't establish connection using TCP/IP protocol. 

As a solution , I was bound to use NamedPipe protocol.

Steps to use NamedPipe protocol:-

1. Enable the NamedPipe protocol on Database server

Go to All Programs >> Microsoft SQL Server 2008 >> Configuration Tools >> SQL Server Configuration Manager >> Select NamedPipe

Right Click on NamedPipe>> Click on Enable

2. For clustered instance named S12345\SQL1 , here is is pipe name

\\.\pipe\$$\S12345\MSSQL$SQL1\sql\query

S12345 -- It is virtual SQL Server name 
SQL1 -- Instance name

3. You must restart SQL Server Services for all the changes to take effect.

4. Enable the NamedPipe protocol on Client server

5. Create Alias on Client server/Client Machine

Create 32 bit alias with following mentioned parameters

a. Alias name : S12345\SQL1
b. Pipe Name : \\S12345.ca.com\pipe\$$\S12345\MSSQL$SQL1\sql\query
c. Protocal : Named Pipe
d. Server : S12345.ca.com (FQDN)



Now, you are ready to use alias in in connection string. 

To validate whether named pipe is being used or not:-

First, you can establish connection from SSMS on client server/your laptop

Second, you can run below query and see the value in net_transport column

Select * from sys.dm_exec_connections order by 1

net_transport -- It must be Namedpipe

Hope it will help you.

Warm Regards,

Chhavinath Mishra
Sr. Specialist Database Administrator

Wednesday, 15 July 2015

SQL Server : To drain all the connections for a particular database

/***********************************************************************
Kill all the spid's attached to a particular database. Very useful when 
continually restoring backups for testing.

***********************************************************************/

Error Msg:

ALTER DATABASE failed because a lock could not be placed on database 'employee'. 


ALTER DATABASE statement failed.

Cannot drop database "employee" because it is currently in use.

Solution: 


To drain all the connections , use bellow SQL to kill all the connections.


use master

go
Sp_killall 'employee'

to verify, use following mentioned code


select * from sys.sysprocesses where dbid = <dbid for your database>


Note: Create this (sp_KillAll Stored Procedure) in the master database, and call it from anywhere; but you can't kill your own process!


*********************Script to create sp_KillAll Stored Procedure *****************


CREATE PROCEDURE sp_KillAll

@DbName VARCHAR(100)
AS


IF db_id(@DbName) = NULL 

BEGIN
    PRINT 'DataBase dose not Exist'
END
ELSE
BEGIN
    DECLARE @spId VARCHAR(30)
        
    DECLARE TmpCursor CURSOR FOR
    SELECT  'Kill ' + CONVERT(VARCHAR, spid)  AS spId
      FROM master..SysProcesses
      WHERE db_Name(dbID) = @DbName
      AND spId <> @@SpId
      AND dbID <> 0
      
    OPEN TmpCursor
        
    FETCH NEXT FROM TmpCursor INTO @spId 
        
    WHILE @@FETCH_STATUS = 0
    BEGIN
        EXEC (@spId)
     
        FETCH NEXT FROM TmpCursor INTO @spId 
    END

    CLOSE TmpCursor

    DEALLOCATE TmpCursor
END 
GO 

Warm Regards,

Chhavinath Mishra 
Sr. Specialist Database Administrator

Tuesday, 14 July 2015

SQL Server : Differences between SSIS 2008 and 2012

SSIS server: SSIS server is no longer a separate service that you connect to, it now appears as a node in Object Explorer when connecting to a SQL Server database instance

SSIS Catalog, which is a database that stores deployed projects, environments, and package execution logs.  Each SSIS server has one catalog.

SSIS Projects -  which is an encapsulation of multiple packages into a single unit that you build, deploy & execute.

SSIS Environments are fairly self-explanatory – they are a wrapper for all environment-specific information (e.g. Connection Strings) that you want to maintain outside of a package and when you execute a package you have to choose which Environment to execute it against. In short Environments are the replacement for SSIS configurations and they work hand-in-hand with Parameters that are also getting introduced in SSIS code-named Denali. 


Data tap: At any path, capture all the data coming through and output it to a text file to review later.  This is done without having to modify the package.


SSIS 2008
SSIS 2012
Undo And Redo
No Undo And Redo feature in SSIS 2008
Undo And Redo feature available in SSIS 2012.
SSIS PARAMETERS
SSIS Parameters at package level
SSIS Parameters at the package level, task level and project level.
DQS TRANSFORMATION
No DQS in SSIS 2008.
DQS Transformation is available in SSIS 2012.
Change Data Capture (CDC)
Introduced in SSIS 2008. But there is no task to support CDC in SSIS 2008.
CDC ControlTask available to support CDC in SSIS 2012.
Data Flow Tap
No Data Tap Available in SSIS 2008.
Data Tap Available in SSIS 2012.
Deployment
Package Level Deployment
Project Level Deployment
Package Level deployment
Logging
Disabled by default
Enabled by default and improved
Newly introduced
-          
SSIS server
SSIS Catalog
SSIS Environments
SSIS Parameters
Shared Connection Managers
Offline Connection Managers
Improved
-          
Column mapper
New Reports included [catalog].[execution_data_statistics] 
 Debug the Script component by setting break points
Execution
runs package locally and uses local components like drivers
When you use the “Run Package” command in SSMS, the package runs on the server,
Version control
-          
Each Package is tracked and can be rolled back

Warm Regards,
Chhavinath Mishra 
Sr. Specialist Database Administrator

Tuesday, 23 June 2015

Verify whether SQL Server Service Account is locked or not

Many times, we need to ensure whether our SQL Server service account (or any other domain account) is locked or not. Here is the command which will help us to get that confirmation for us.

For example: I would like to perform this test for account named mydomin.com\sqsqlserver.

SQL Server service account name: mydomin.com\sqsqlserver.

Imp Note: We have to logged in to domain whether our account exist as this command run on primary domain controller. I always run this command from database server which belongs to same domain.

-------------------------------------------------------------------------------------------------------

C:\Users\Chhavi>net user sqsqlserver /domain
The request will be processed at a domain controller for domain mydomin.com.


User name                    sqsqlserver
Full Name                    sqsqlserver
Comment                      SQL Server service account , Chhavinath Mishra
User's comment
Country/region code          000 (System Default)
Account active               Locked
Account expires              Never

Password last set            2015-05-07 5:41:32 AM
Password expires             Never
Password changeable          2015-05-08 5:41:32 AM
Password required            Yes
User may change password     Yes

Workstations allowed         All
Logon script
User profile
Home directory
Last logon                   2015-05-07 5:45:33 AM

Logon hours allowed          All

Local Group Memberships      *ADM_Test1
Global Group memberships     *Domain Users         *User_ServiceAccountNo
The command completed successfully.

Warm Regards,
Chhavinath Mishra 
Sr. Specialist Database Administrator