Wednesday, March 26, 2014

Differences between SQL Server High availability features


There are 5 methods of SQL high availability are available in SQL Server.

1.    Logshipping
2.    Replication
3.    Database Mirroring
4.    Always on
5.    Failover Cluster

Feature
DB Mirroring
Replication
Log Shipping
FailoverClustering
Always On
Server Level
No
No
No
Yes
No
Database Level
Yes
Yes
Yes
No
Yes
Automatic Failover
Yes (Only HA Option)
No
No
Yes
Yes
Automatic Failure Detection
Yes (Only in HA option)
No
No
Yes
yes
Hot, Warm or Cold standby
Hot and Warm Options
Warm
Warm
Hot
Hot and Warm Options
Server Level Objects Failover
Manual
Manual
Manual
Yes (Automatic)
Yes (Automatic)
Is data on Failover available for queries while the Primary server is running?
Yes (use Database Snapshots)
Yes
Yes (Standby Mode)
No
no
Are changes allowed at Failover location?
No
Yes (Merge and TRN Replication with updating subscribers)
No
No
no
Is Main and Failover server in a 1-1 relationship?
Yes
Not Required
Not Required
Yes
yes
Is 1-Many relationship possible between the Main and Failover servers?
No
Yes
Yes
No
yes
Is Many-1 relationship possible between Main and Failover server?
No
Yes
No
No
yes
Is Automatic Application redirection possible after failover?
Yes
No
No
Yes
yes
Recovery model required for the participating databases?
FULL
ANY
FULL & BULK
Any
full
Can you filter what data is sent to the Failover server?
No
Yes
No
No
no
Where does the logic HA reside?
Sql
Replication Agents (they run outside Sql Server
Sql Agents (Run outside Sql Server)
OS + Sql
OS + Sql
If you want a reports server, what is the best solution?
Works, but needs constant refresh of the Snapshot database for latest data.
Best Option.
Works, but users connections need to be kicked out, when new log is applied.
Not Possible
Best Option.
Best solution if the Main and Failover server are separated by long distance?
Works, but not recommended.
Works, but with high latency
Best Option. (Log compression reduces latency significantly.
Not good.
Works, but with high latency

Please let me know if still need to update anything, I will update the same.



Tuesday, March 25, 2014

Using FileTables in SQL Server 2012

Using FileTables in SQL Server 2012

FileTables, a new feature introduced in SQL Server 2012, is a unique table that reflects metadata of files in a specified folder.

Enabling File stream at instances level.


Enable Filestream for the instance in question from SQL Server Configuration Manager (Right click on the SQL Server Service-> Properties->Filestream-> Enable Filestream for Transact-SQL access). Also make sure you provide a Windows Share name. Restart SQL after making this change. 
The second method of enabling FileStream is by using the stored procedure "sp_configure". This stored procedure requires two parameters: "filestream_access_level" and the security level.


EXEC sp_configure filestream_access_level, 2
RECONFIGURE
Go


If you attempt running the sp_configure stored procedure prior to configuring it at the instance level, you'll receive the following error:
Configuration option 'filestream access level' changed from 0 to 2. Run the RECONFIGURE statement to install.

Msg 5591, Level 16, State 1, Line 2
FILESTREAM feature is disabled.

Otherwise, when successful you'll receive the following message:
Configuration option 'filestream access level' changed from 0 to 2. Run the RECONFIGURE statement to install.

Provide a FileStream Filegroup
The next step is to provide a FileStream FileGroup. This can be incorporated in the CREATE DATABASE command


CREATE DATABASE FTableDB
ON PRIMARY
(Name = FTableDB,
FILENAME = 'D:\FTable\FTABLEDB.mdf'),
FILEGROUP FTFG CONTAINS FILESTREAM
(NAME = FTableFS,
FILENAME='D:\FTable\FS')
LOG ON
(Name = FTableDBLog,
FILENAME = 'D:\FTable\FTABLEDBLog.ldf')
WITH FILESTREAM (NON_TRANSACTED_ACCESS = FULL,
DIRECTORY_NAME = N'FTableDB');
GO


After executing the above statement, you'll see the new additions to the "FTables" folder
A FileTable folder in Object Explorer that was created by default.
Enable Non-Transactional Access at the Database Level
Because FileTable allows modifications to be performed via Windows applications without requiring a transaction, I have to enable non-transactional access. To do so, I execute the SQL statement below. Note a directory name is specified -- this is the directory that will store files used with the FileTable.


ALTER DATABASE FTABLEDB
SET FILESTREAM (NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'FTABLE')


Create a FileTable
The final step for configuring FileTables is to create the FileTable itself. This is accomplished by executing a bit of SQL:

Use FTABLEDB
Go

CREATE TABLE FTABLE AS FileTable
GO


Note that there was no structure specified for the table. The FileTable was created using the default schema containing 17 fields.

If you right-click the newly created FileTable ("FTABLE") and select "Explore FileTable Directory", a new window will open, directing you to the corresponding folder.
Now you can save files into databases those files will be automatically possible to see.





Monday, March 24, 2014

WHAT’S MISSING IN SQL AZURE

As you start working with SQL Azure, or, if you are already familiar with SQL Azure, you will at some point wonder why SQL Azure doesn’t have a specific feature or functionality you are looking for, such as Full-Text Search. For example, if you were to do a feature-to-feature comparison you would quickly see that at least the following features are not present in SQL Azure:

  • ·         SQLCLR
  • ·         Full-Text Search
  • ·         Replication
  • ·         SQL Agent
  • ·         Encryption (TDE)


This is not a complete list, but the complete list is not a long one either. It is not publicly known the reason for the lack of certain features and functionality in SQL Azure. However, this section can at least provide information on some of the items in the above list.

The SQLCLR is in fact “partially” supported. For example, the XML and Spatial data types are actually CLR data types, and you will certainly find these data types in SQL Azure. What SQL Azure doesn’t support for SQLCLR is the ability to create assemblies in managed code and deploy those to SQL Azure. It is unknown if and when that will be supported.

Replication really isn’t needed, because of the existence of SQL Azure Data Sync Services. SQL Azure Data Sync Services works far better and is far easier to configure and use than Replication. Data Sync Services is built entirely on top of the Sync Framework and therefore includes a much richer data synchronization platform for moving data, including conflict handling and status reporting.

Microsoft is working hard at including encryption but there are certain problems they need to solve before you will see it included. The big issue really is how to support multiple levels of encryption in a shared environment. Remember that SQL Azure is a shared environment, and as such, databases are spread out over multiple instances. For example, my database and your database could potentially be located on the same server. In this scenario, the problem arises when I use one level of encryption and you use another.


These are several examples of missing features and depending on the feature, it will elicit a different response. For example, SQL Azure has SQL Azure Reporting Services, but where is the rest of the Business Intelligent (BI) stack of Analysis Services and Integration Services? Microsoft is working on them, but when and how they will be included is yet to be seen. The moral of this story is that some features you just won’t see because it doesn’t make sense to include them, as is the case in Replication. With other features you just need to be patient.

Friday, March 21, 2014

SQL Server 2012 New features

SQL Server 2012 was released on April 2012 and it has started becoming favorite among professionals. Any new product comes from Microsoft the first thing I personally ask myself, is it worth to jump in?. Is it worth to spend customer’s hard earned money to get in to that product?. The way to assess the same is dividing the product features in to   “revolution” and “evolution”. “Revolution” means it’s completely a new thing while “evolution” means there was something already and it has been improvised.

1.      AlwaysOn Availability Groups -- This feature takes database mirroring to a whole new level. With AlwaysOn, users will be able to fail over multiple databases in groups instead of individually. Also, secondary copies will be readable, and can be used for database backups. The big win is that your DR environment no longer needs to sit idle.

2.      Windows Server Core Support -- If you don't know what Windows Server Core is, you may want to come up to speed before Windows 8 (MS is making a push back to the command line for server products). Core is the GUI-less version of Windows that uses DOS and PowerShell for user interaction. It has a much lower footprint (50% less memory and disk space utilization), requires fewer patches, and is more secure than the full install. Starting with SQL 2012, it is supported for SQL Server.

3.      BI Semantic Model -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics.

4.      BI Semantic Model -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics

5.      Sequence Objects -- For those folks who have worked with Oracle, this has been a long requested feature. A sequence is just an object that is a counter -- a good example of it's use would be to increment values in a table, based a trigger. SQL has always had similar functionality with identity columns, but now this is a discrete object.


6.      Enhanced PowerShell Support -- Windows and SQL Server admins should definitely start brushing up on their PowerShell scripting skills. Microsoft is driving a lot of development effort into instrumenting all of their server-based products with PowerShell. SQL 2008 gave DBAs some exposure to it, but there are many more in cmdlets in SQL 2012.

7.      Distributed Replay -- Once again this is answer to a feature that Oracle released (Real Application Testing). However, and in my opinion where the real value proposition of SQL Server is, in Oracle it is a (very expensive) cost option to Enterprise Edition. With SQL, when you buy your licenses for Enterprise Edition, you get everything. Distributed replay allows you to capture a workload on a production server, and replay it on another machine. This way changes in underlying schemas, support packs, or hardware changes can be tested under production conditions.


8.       PowerView -- You may have heard of this under the name "Project Crescent" it is a fairly powerful self-service BI toolkit that allows users to create mash ups of BI reports from all over the Enterprise.

9.      SQL Azure Enhancements -- These don't really go directly with the release of SQL 2012, but Microsoft is making some key enhancements to SQL Azure. Reporting Services for Azure will be available, along with backup to the Windows Azure data store, which is a huge enhancement. The maximum size of an Azure database is now up to 150G. Also Azure data sync allows a better hybrid model of cloud and on-premise solutions

10.  Big Data Support -- I saved the biggest for last, introduced at the PASS (Professional Association for SQL Server) conference last year, Microsoft announced a partnership with Hadoop provider Cloudera. One part of this involves MS releasing a ODBC driver for SQL Server that will run on a Linux platform. Additionally, Microsoft is building connectors for Hadoop, which is an extremely popular NoSQL platform. With this announcement, Microsoft has made a clear move into this very rapidly growing space.

11.   Column store Indexes -- This a cool new feature that is completely unique to SQL Server. They are special type of read-only index designed to be use with Data Warehouse queries. Basically, data is grouped and stored in a flat, compressed column index, greatly reducing I/O and memory utilization on large queries.

12.   User-Defined Server Roles -- DBAs have always had the ability to create custom database role, but never server wide. For example, if the DBA wanted to give a development team read/write access to every database on a shared server, traditionally the only ways to do it were either manually, or using undocumented procedures. Neither of which were good solutions. Now, the DBA can create a role, which has read/write access on every DB on the server, or any other custom server wide role

13.  Contained Database In simple terms it is a database that is isolated from other databases, and isolated from the instance of SQL Server that is hosting the database.


·         There are four ways that SQL Server 2012 helps to isolate databases from the instance:
·         Much of the metadata that describes a database is maintained in the database and not in the master database
·         All metadata is defined using the same collation
·         User authentication can be performed by the database, reducing the database’s dependency on the logins of the instance of SQL Server

·         The SQL Server environment reports, DMVs and xEvents can act upon containment information.