Professional Documents
Culture Documents
SQL Server 2012-New Features
SQL Server 2012-New Features
SQL Server 2012-New Features
Specialized Editions
Developer Web Express
Hardware Requirements
Software Requirements
Manageability Enhancements
SQL Server Management Studio IntelliSense Enhancements A new Insert Snippet menu Transact-SQL Debugger Enhanced Resource Governor
number of resource pools Resource Governor maximum cap for CPU usage introduced resource pools can be affinitized to an individual schedule or a
group of schedules
Contained Databases
Startup Options Relocated
Presenter: Juhi Mahajan
Programmability Enhancements
FileTable
Contained Database Sequences
Filestream Enhancements
New Data/Time Functions ResultSet Enhancement Fetch & Offset Error Handling Enhancements
CONTAINED DATABASES
tables, views procedures users DB1 Instance tables, views procedures users DB1
Contained Database
A contained database is a concept in which a database includes all the settings and metadata required to define the database and has no configuration dependencies on the instance of the SQL Server Database Engine where the database is installed.
NOTE: SQL Server Denali aka SQL Server 2012 supports only partial contained database
Presenter: Juhi Mahajan
Terms
Database boundary The boundary between a database
and the instance of SQL Server. The boundary between a database and other databases Uncontained An user entity that crosses beyond application boundary. In other words you can access resources outside your application boundary. Contained An user entity that resides within an application boundary. Partial Contained database Its a contained database which also allows you to access the objects outside. Full Contained database Full containment wont allow you to access the objects outside the application boundary.
Terms
Contained user - There are two types of users for contained databases. Contained database user with password - Contained database users with passwords are authenticated by the database. Windows principals - Authorized Windows users and members of authorized Windows groups can connect directly to the database and do not need logins in the master database. The database trusts the authentication by Windows.
Terms
Database Boundary - Because partially contained databases separate the database functionality from those of the instance, there is a clearly defined line between these two elements called the database boundary. Inside of the database boundary is the database model, where the databases are developed and managed. Ex: sys.tables Outside of the database boundary is the management model, which pertains to instance-level functions and management. Ex: sys.endpoints
Database Administration
functions with collation changes Binding change resulting from collation changes, including references to objects, columns, symbols, or types. Replication, change data capture, and change tracking
Presenter: Juhi Mahajan
Now lets connect to the server with contained database user. You need to specify the database name in the connection string or else you wont be able to connect to the server
Presenter: Juhi Mahajan
When user tries to execute this procedure, he gets permission denied error
SEQUENCE
Sequence - Definition
SEQUENCE allows you to define a single point of repository where SQL Server will maintain in memory counter. Only The last-used value is stored in memory and so no storage is required. Sequence object provides, as the name suggests, a sequence number based in the specification in which the sequence object was created.
Table Specific
You cannot obtain the new value in your application before using it You cannot add or remove the property from an existing column You cannot generate new values in an UPDATE statement when needed, rather only in INSERT statements The semantics of defining ordering in a multirow insert are confusing, and in SELECT INTO statements are actually not guaranteed You cannot define: minimum and maximum values, allow cycling, and caching options You can reseed an identity property, but you cannot change the step size
Table Independent
You can obtain the new value before using it in an INSERT statement You can add or remove a default constraint defined for a column with an expression that generates a new sequence value You can generate new values in an UPDATE statement
The semantics of defining ordering in a multi-row insert are very clear using an OVER clause, and are even allowed in SELECT INTO statements You can define minimum and maximum values, whether to allow cycling, and a cache size option for performance You can alter any of the properties of a sequence object besides the data type, including the current value, increment, minimum value, maximum value, cycle and cache size
You cannot obtain a whole range of new identity values in one shot, letting the application assign the individual values
You can obtain a whole range of new sequence values in one shot using the stored procedure sp_sequence_get_range, letting the application assign the individual values for increased performance
Example:
same sequence generator in a single statement must all use the same OVER clause definition. An OVER clause applied to the NEXT VALUE FOR function does not support the PARTITION BY sub clause. The OVER clause is not allowed in UPDATE or MERGE statements.
Presenter: Juhi Mahajan
Limitations of Sequence
You are not allowed to use NEXT VALUE FOR in a: UNION, EXCEPT, INTERSECT, or with DISTINCT directly in a statement that uses a DISTINCT, UNION (except UNION ALL), EXCEPT or INTERSECT operator. check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, sub-queries, common table expressions, or derived tables. TOP, OVER, OUTPUT, ON, WHERE, GROUP BY, HAVING, ORDER BY, COMPUTE, or COMPUTE BY clause. MERGE or UPDATE
instead of the database file itself, but we can "insert" or "select" the file just like it was stored on SQL Server database. Designed to solve the problem of unstructured large object (LOB) storage, it combines the performance of file system streaming APIs with the transactional integrity of the relational database. With this data type, the unstructured data is stored in the NTFS file system, and the SQL Server engine manages the link between the FILESTREAM columns and the files in the file systemincluding backing up and restoring file system data.
Presenter: Juhi Mahajan
MB Fast read access is important. You are developing applications that use a middle tier for application logic. For smaller objects, storing varbinary(max) BLOBs in the database often provides better streaming performance.
column in which the data is stored as BLOBs in the file system. The standard varbinary(max) limitation of 2-GB file sizes does not apply to BLOBs that are stored in the file system. FILESTREAM data must be stored in FILESTREAM filegroups. When a table contains a FILESTREAM column, each row must have a unique row ID. FILESTREAM data containers cannot be nested. Multiple data containers can be added to a FILESTREAM filegroup. FILESTREAM filegroups can be on compressed volumes. For the FILESTREAM data type the drive volume that has the files must be in NTFS format. Presenter: Juhi Mahajan
NOTE: In order to enable the FILESTREAM feature you need to be a member of the SYSADMIN or SERVERADMIN Presenter: Juhi Mahajan fixed server roles.
supports it. As the FILESTREAM uses a special type of filegroup, you must specify the CONTAINS FILEGROUP clause for least one filegroup. For a FILESTREAM filegroup, FILENAME refers to a path. The path up to the last folder must exist, and the last folder must not exist. After you run the sample code, you should see the FileStream folder on your drive. This folder contains a filestream.hdr file and an $FSLOG folder.
application uses this token to obtain a Win32 handle and operate on BLOB) data. GET_FILESTREAM_TRANSACTION_CONTEXT() returns a token that represents the current transaction of a session. An application uses this token to bind FILESTREAM file system streaming operations to the transaction.
PathName
Returns the path of a FILESTREAM binary large object (BLOB). PathName is read-only. Syntax: column_name.PathName (@option) @option : An integer expression that defines how the server component of the path should be formatted. Default 0 Value Description 0 Returns the server name converted to BIOS format 1 Returns the server name without conversion 2 Returns the complete server path
GET_FILESTREAM_TRANSACTION_CONTEXT
Returns a token that represents the current transaction context of a session. The token is used by an application to bind FILESTREAM file-system streaming operations to the transaction. Syntax: GET_FILESTREAM_TRANSACTION_CONTEXT ()
Return Value: varbinary(max) NULL : If the transaction has not been started, or has been canceled or committed.
Presenter: Juhi Mahajan
FILETABLE
A FileTable is a specialized user table with a pre-defined schema that stores FILESTREAM data, as well as file and directory hierarchy information and file attributes.
FileTable feature allows organizations to store files and documents within a special table in SQL Server and the ability to access those files and documents from windows.
FILETABLE
A FileTable provides following functionality: It stores data related to all the nodes in that hierarchy, for both directories and the files they contain Every row contains the following items: A FILESTREAM column for stream data and a file_id (GUID) identifier. Both path_locator and parent_path_locator columns for representing and maintaining the file and directory hierarchy. 10 file attributes such as created date and modified date that are useful with file I/O APIs. A type column that supports full-text search and semantic search over files and documents.
Presenter: Juhi Mahajan
Server database. Windows API compatibility includes the following: Non-transactional streaming access and in-place updates to FILESTREAM data. A hierarchical namespace of directories and files. Storage of file attributes, such as created date and modified date. Support for Windows file and directory management APIs. Compatibility with other SQL Server features including management tools, services, and relational query capabilities over FILESTREAM and file attribute data.
NOTE: To check out if FileStream options are enabled at the database level use sys.database_filestream_options
level, you can optionally provide a directory name by using the DIRECTORY_NAME option.
In the FileTable folder hierarchy, this database-level directory
becomes the child of the share name specified for FILESTREAM at the instance level, and the parent of the FileTables created in the database. Syntax: CREATE DATABASE database_name WITH FILESTREAM ( NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'directory_name' ); GO Presenter: Juhi Mahajan
Creating a FileTable
Create a FileTable by calling the CREATE TABLE (Transact-SQL)
statement with the AS FileTable option FileTable has a fixed schema, you do not have to specify a list of columns You can specify the following settings for the new FileTable: FILETABLE_DIRECTORY FILETABLE_COLLATE_FILENAME Names to be used for the 3 primary key and unique constraints that are automatically created NOTE: When a FileTable is created, some system-defined indexes and constraints are created. To see these objects, query the catalog view sys.filetable_system_defined_objects. These objects cannot be altered.
Index type
Primary Key, non-clustered Unique, non-clustered Unique, non-clustered
DATEFROMPARTS Function
The DATEFROMPARTS function, returns a date value with the date part set to the specified year, specified month and the specified day, and the time portion set to the default: Syntax: DATEFROMPARTS ( year, month, day ) Arguments: Year: Integer expression specifying a year. Month: Integer expression specifying a month, from 1 to 12. Day: Integer expression specifying a day. Return Type: Date
Presenter: Juhi Mahajan
TIMEFROMPARTS Function
The TIMEFROMPARTS function returns a full time value Syntax:
TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )
Arguments: Hour: Integer expression specifying hours. Minute: Integer expression specifying minutes. Seconds: Integer expression specifying seconds. Fractions: Integer expression specifying fractions. Precision: Integer literal specifying the precision of the time value to be returned. Return Type: Time ( precision )
Presenter: Juhi Mahajan
DATETIMEFROMPARTS Function
The DATETIMEFROMPARTS function returns a full datetime value Syntax: DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds ) Arguments: Year: Integer expression specifying a year. Month: Integer expression specifying a month. Day: Integer expression specifying a day. Hour: Integer expression specifying hours. Minute: Integer expression specifying minutes. Seconds: Integer expression specifying seconds. Milliseconds: Integer expression specifying milliseconds. Return Type: Datetime Presenter: Juhi Mahajan
DATETIMEOFFSETFROMPARTS function
The DATETIMEOFFSETFROMPARTS function returns a full datetimeoffset data type as shown in the below query result. The OFFSET argument is basically used to represent the time zone offset value hour and minutes. If the offset arguments are omitted, then the time zone offset is assumed to be 00:00, that is, there is no time zone offset. Syntax: DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision )
DATETIMEOFFSETFROMPARTS function
Arguments: Year: Integer expression specifying a year. Month: Integer expression specifying a month. Day: Integer expression specifying a day. Hour: Integer expression specifying hours. Minute: Integer expression specifying minutes. Seconds: Integer expression specifying seconds. Fractions: Integer expression specifying fractions. Hour_offset: Integer expression specifying the hour portion of the time zone offset. Minute_offset: Integer expression specifying the minute portion of the time zone offset. Precision: Integer literal specifying the precision of the datetimeoffset value to be returned. Return Type: datetimeoffset ( precision ) Presenter: Juhi Mahajan
EOMONTH Function
The EOMONTH function calculates the last date of the month based on the date which is passed as an input parameter. Syntax: EOMONTH ( start_date [, month_to_add ] ) Arguments: start_date: Date expression specifying the date for which to return the last day of the month. month_to_add: Optional integer expression specifying the number of months to add to start_date. If this argument is specified, then EOMONTH adds the specified number of months to start_date, and then returns the last day of the month for the resulting date. If this addition overflows the valid range of dates, then an error is raised. Return Type: Presenter: Juhi Mahajan Date
Throw Statement
Microsoft introduced the TRYCATCH construct in SQL Server 2005 which helped database developers to effectively handle errors within their T-SQL code. SQL Server 2012, THROW statement doesnt require an error number to exist within the sys.messages table however, the error number used should be greater than 50000. All exceptions raised using the THROW statement will have a severity of 16 and the statement before the THROW statement must be followed by the semicolon (;) statement terminator.
THROW (Transact-SQL)
Syntax: THROW [ { error_number | @local_variable }, { message | @local_variable }, { state | @local_variable } ] [ ; ] Arguments: error_number: Is an integer constant or variable that represents the exception; must be greater than or equal to 50000 and less than or equal to 2147483647. Message: Is an string or variable that describes the exception. message is nvarchar(2048). State: Is a constant or variable between 0 and 255 that indicates the state to associate with the message. state is tinyint. NOTE: If the THROW statement is specified without parameters, it must appear inside a CATCH block. This causes the caught exception to be raised. Any error that occurs in a THROW statement causes the statement batch to be endedPresenter: Juhi Mahajan
ORDER Clause
Syntax: ORDER BY order_by_expression [ COLLATE collation_name ] [ ASC | DESC ] [ ,...n ] [ <offset_fetch> ]
<offset_fetch> ::= { OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS } [ FETCH { FIRST | NEXT } {integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY ] Presenter: Juhi Mahajan }
clause cannot exceed 8,060 bytes Columns of type ntext, text, image, geography, geometry, and xml cannot be used in an ORDER BY clause In a query that uses UNION, EXCEPT, or INTERSECT operators, ORDER BY is allowed only at the end of the statement The ORDER BY clause is not valid in views, inline functions, derived tables, and subqueries, unless either the TOP or OFFSET and FETCH clauses are also specified. OFFSET and FETCH are not supported in indexed views or in a view that is defined by using the CHECK OPTION clause
Presenter: Juhi Mahajan
UPDATE, MERGE, and DELETE statements, but can be specified in a subquery defined in these statements. In a query that uses UNION, EXCEPT or INTERSECT operators, OFFSET and FETCH can only be specified in the final query that specifies the order of the query results. TOP cannot be combined with OFFSET and FETCH in the same query expression (in the same query scope).
Presenter: Juhi Mahajan
requires running the query one time for each "page" of data returned to the client application. To achieve stable results between query requests using OFFSET and FETCH, the following conditions must be met:
The underlying data that is used by the query must not
change. The ORDER BY clause contains a column or combination of columns that are guaranteed to be unique
Presenter: Juhi Mahajan
which lets you redefine the name and data types of the columns being returned from the stored procedure. WITH RESULT SETS clause with the EXECUTE statement. The WITH RESULT SETS clause can also be used with a stored procedure, which returns multiple result sets and for each result set you can define the column name and data types for each column separately. If you want to restrict a stored procedure to return a result set you can use the RESULT SETS NONE clause. The WITH RESULT SETS option cannot be specified in an INSERTEXEC statement. The number of columns being returned as part of result set cannot be changed. Presenter: Juhi Mahajan
Availability Enhancements
o AlwaysOn Availability Groups
o AlwaysOn Failover Cluster Instances (FCI) o Support for Windows Server Core
In SQL Server 2012, the startup Parameter option has been relocated to its own tab and can be easily accessed from SQL Server Configuration Manager.
CONFIGURING STARTUP PARAMETERS USING SQL SERVER 2012 1. Launch SQL Server Configuration Manager from Configuration Tools folder 2. Click on SQL Server Services from the Left Pane. You should now see all the services associated with SQL Server on the right pane. 3. From the right pane, right-click on the SQL Server Instance you wish to configure startup options for and then click Properties 4. You will notice a new tab called Startup Parameter. You can now specify the startup option by typing the parameter in the Specify a Startup Parameter box. 5. Once done, click OK button. 6. Restart SQL Server Database Engine for changes to take effect. Presenter: Juhi Mahajan
Is the fully qualified path for the master database file If you do not provide this option, the existing registry parameters are used. Is the fully qualified path for the error log file Is the fully qualified path for the master database log file
Presenter: Juhi Mahajan
-e error_log_path
-l master_log_path
-c
-f
-m
mode.
-s Allows you to start a named instance of SQL Server.
Presenter: Juhi Mahajan
availability and disaster-recovery solution that provides an enterprise-level alternative to database mirroring. An availability group supports a failover environment for a discrete set of user databases, known as availability databases, that fail over together. An availability group supports a set of read-write primary databases and one to four sets of corresponding secondary databases. Optionally, secondary databases can be made available for read-only access and/or some backup operations. Deploying AlwaysOn Availability Groups requires a Windows Server Failover Clustering (WSFC) cluster. Each availability replica of a given availability group must reside Presenter: Juhi Mahajan on a different node of the same WSFC cluster
Benefits
Supports up to five availability replicas
Supports alternative availability modes, as follows: Asynchronous-commit mode. Synchronous-commit mode. Supports a flexible failover policy for greater control
over availability-group failover Supports encryption and compression, which provide a secure, high performing transport.
Achieving high availability and disaster recovery with AlwaysOn Availability Groups
SSIS Enhancements
SSIS Toolbox You now work with the SSIS Toolbox to add tasks
and data flow components to a package, rather than with the Visual Studio toolbox Parameters The package designer includes a new tab to open the Parameters window for a package. Variables button This new button on the package designer toolbar provides quick access to the Variables window. SSIS Toolbox button This button is also new in the packagedesigner interface and allows you to open the SSIS Toolbox when it is not visible.
upgrade to Visual Studio Tools for Applications (VSTA) 3.0 and includes support for the Microsoft .NET Framework 4.0.
Presenter: Juhi Mahajan
SSIS Enhancements
Undo and Redo You can now make edits in either the
control flow or data flow designer surface, and you can use Undo to reverse a change or Redo to restore a change you had just reversed. Status Indicators After executing a package, the status of each item in the control flow and the data flow displays in the package designer.
construct a variable value at runtime. Execute Package Task The Execute Package Task has been updated to include a new property, ReferenceType, You use this property to specify the Location of the package to execute.
you easily create a source or a destination and its corresponding connection manager. ODBC Source and Destination The ODBC Source supports Table Name and SQL Command as data-access modes, whereas data-access modes for the ODBC Destination are Table Name Batch and Table Name Row By Row. DQS Cleansing Transformation Its purpose is to help you improve the quality of data by using rules that are established for the applicable knowledge domain. You can create rules to test data for common misspellings in a text field or to ensure that the column length conforms to a standard specification.
Presenter: Juhi Mahajan
SSRS Enhancements
New Renderers Excel 2010 Renderer Word 2010 Renderer SharePoint Shared Service Architecture Service Application Configuration Subscriptions Power View It is a browser-based Silverlight
application that requires Reporting Services to run in SharePoint integrated mode using SharePoint Server 2010 Enterprise Edition.
Presenter: Juhi Mahajan
SSAS Enhancements
Server Modes for Analysis Services Instances:
Multidimensional, Tabular, and SharePoint Removal of the 4 Gigabyte Limit on String Storage for MOLAP Engine DistinctCount Performance Improvement in ROLAP Processing PowerPivot for Excel (SQL Server 2012) PowerShell for PowerPivot for SharePoint