
SQL Server 2014 Development Essentials
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Book DescriptionThis book is an easy-to-follow, comprehensive guide that is full of hands-on examples, which you can follow to successfully design, build, and deploy mission-critical database applications with SQL Server 2014. If you are a database developer, architect, or administrator who wants to learn how to design, implement, and deliver a successful database solution with SQL Server 2014, then this book is for you. Existing users of Microsoft SQL Server will also benefit from this book as they will learn what's new in the latest version.What you will learn
Who this book is for
All prices
More details
Other editions
Additional editions

Person
Basit A. Masood-Al-Farooq is an internationally known Lead SQL DBA, trainer, and technical author with twelve years' experience of the Microsoft technology stack. He is an accomplished development and production SQL Server DBA with a proven record of delivering major projects on time and within budget. He is an expert at evaluating the clients' needs against the capabilities of the SQL Server product set, with the objective of minimizing costs and maximizing functions by making innovative use of advance capabilities. Basit has authored numerous SQL Server technical articles on various SQL Server topics for different SQL Server community sites, which include SQLMag.com, MSSQLTips.com, SQLServerCentral.com, SSWUG.org, SQL-Server-Performance.com, and SearchSQLServer.com. He has also developed and implemented many successful database infrastructures, data warehouses, and business intelligence projects. He holds a Master's degree in Computer Science from London Metropolitan University and industry-standard certifications from Microsoft, Sun, Cisco, Brainbench, ProSoft, and APM, which include MCITP Database Administrator 2008, MCITP Database Administrator 2005, MCDBA SQL Server 2000 and MCTS .NET Framework 2.0 Web Applications. He also has a good understanding of ITIL principles. He can be reached via Twitter (@BasitAali), his blog (http://basitaalishan.com), or via LinkedIn (http://uk.linkedin.com/in/basitfarooq). He was a technical reviewer for SQL Server 2012 Reporting Services Blueprints, Marlon Ribunal and Mickey Stuewe, Packt Publishing and Reporting with Microsoft SQL Server 2012, James Serra and Bill Anton, Packt Publishing.
Content
Database Design Principals
Understanding DDL and DCL Statements
Data Retrieval with SQL Server Transact-SQL statements
Data Modification with SQL Server Transact-SQL statements
Database Objects and Error Handling
Performance Basics
Creating and modifying databases
You can use either Transact-SQL DDL statements or SQL Server Management Studio to create and modify databases. In the following subsections, we will discuss these options.
Create, modify, and drop databases with T-SQL DDL statements
In this section, we will cover Transact-SQL DDL statements that are used to create, alter and modify SQL Server databases.
Creating a database with T-SQL DDL statements
We use the CREATE DATABASE statement to create a new database on SQL Server. The general syntax for the CREATE DATABASE command is as follows:
The following are the arguments of the CREATE DATABASE command:
database_name: This is the name of new SQL Server database. The database name must be unique with an instance of SQL Server.CONTAINMENT: This is used to specify the containment status of the database. SpecifyNONEfor non-contained databases, andPARTIALfor partially contained databases.ON [PRIMARY]: This is used to specify the files in the primary filegroup. If this parameter is not specified, the first file in the list becomes the primary file for the database.LOG ON: This is used to specify the location for the transaction log files.filespec: Thefilespecarguments are used to control file properties. This option is supported for both the data and transaction log file. Thefilespecparameters include:Name: This is the logical name of the database. We use this name in Transact-SQL statements to refer to the file.FILENAME: This specifies the operating system name and file path.Note
SQL Server 2014 Database Engine enables you to store SQL Server database files as Windows Azure Blobs Storage. This is one of the new features of SQL Server 2014. For more information about this feature, refer to the SQL Server Data Files in Windows Azure article at http://msdn.microsoft.com/en-us/library/dn385720.aspx.
Size: This is the initial size of the database file. The value can be specified in KB, MB, GB, or TB.MAXSIZE: This is used to specify the maximum size limit for the database file. The value can be specified in KB, MB, GB, TB, or asUNLIMITED.FILEGROWTH: This is used to specify the automatic growth increments for the database file. The value can be specified in KB, MB, GB, TB, or percentage (%).
COLLATE: This specifies the default collation setting for the database. If not specified, the server default collation is used as the database collation. For more information about the Windows and SQL collation names, refer to the COLLATE (Transact-SQL) topic at http://msdn.microsoft.com/en-gb/library/ms184391(v=sql.120).aspx.WITH <option>: This is used to configure the following external excess options:DEFAULT_FULLTEXT_LANGUAGEDEFAULT_LANGUAGEDB_CHAINING, TRUSTWORTHYNESTED_TRIGGERSTWO_DIGIT_YEAR_CUTOFFTRANSFORM_NOISE_WORDS
Note
A detailed discussion about a database's external excess options is beyond the scope of this chapter. For help with this, refer to http://technet.microsoft.com/en-us/library/ms176061(v=sql.120).aspx.
Example 1 - creating a database based on a model database
The following CREATE DATABASE script creates a CH02_01 database using the default parameters from the model database:
Tip
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Example 2 - creating a database that explicitly specifies the database data and the transaction log file's filespecs properties
The following CREATE DATABASE script creates the CH02_02 database by explicitly specifying data and the transaction log file's filespecs properties:
Example 3 - creating a database on multiple filegroups
The following CREATE DATABASE script creates the CH02_03 database on the following two filegroups:
- The primary filegroup, which contains
CH02_03DAT01andCH02_02DAT02 - The user-defined filegroup,
CH02_FG1, which only contains the database file, that is,CH02_03DAT03
The following code generates the CH02_03 database:
Modifying a database with T-SQL DDL statements
We use ALTER DATABASE to modify an existing SQL Server database. Some common situations for modifying an existing SQL Server database include:
- Adding or removing filegroups and database files to an existing database
- Adding or removing transaction log files to an existing database
- Manually expanding data and/or transaction log file sizes
- Changing data and/or transaction log file growth settings
- Setting database options
- Changing the database default collation
The following is the basic syntax for the ALTER DATABASE statement:
The following are the arguments of the ALTER DATABASE command:
database_name: This is the name of a new SQL Server database. The database name must be unique with an instance of SQL Server.ADD FILE: This argument adds a file to the database.TO FILEGROUP: This will be the name of the filegroup to which the specified file will be added.REMOVE FILE: This argument removes a file from the database.MODIFY FILE: This argument specifies the file that should be modified.
Example - adding a secondary data file to an existing database
The following example uses ALTER DATABASE to add a secondary data file to the CH2_03 database user-defined filegroup (CH02_FG1):
You can also use the SET clause of the ALTER DATABASE statement to change database options. For example, you can run the following command to set the recovery model of the CH02_03 database to FULL:
Dropping a database with T-SQL DDL statements
When you no longer need a database, you can use the DROP DATABASE statement to delete the database from SQL Server. The following is the basic syntax for DROP DATABASE:
For example, you run the following command to drop the...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.