Published on

June 28, 2011

Understanding SQL Server Concepts

SQL Server is a powerful relational database management system that is widely used in the industry. It provides various features and functionalities that allow developers and administrators to efficiently manage and manipulate data. In this article, we will discuss some important concepts and ideas related to SQL Server.

Error Handling in SQL Server 2008

SQL Server 2008 introduced the TRY…CATCH construct for error handling. This allows developers to build error handling logic at the desired level and handle errors in a structured manner. The basic structure of TRY…CATCH is as follows:

BEGIN TRY
    -- Code block where errors may occur
END TRY
BEGIN CATCH
    -- Code block to handle errors
END CATCH

If any error occurs within the TRY block, the execution is diverted to the CATCH block, where the error can be resolved or handled appropriately.

RAISERROR in SQL Server

RAISERROR is a command in SQL Server that generates an error message and initiates error processing for the session. It can reference a user-defined message stored in the sys.messages catalog view or build a message dynamically. The error message is returned to the calling application or to an associated CATCH block of a TRY…CATCH construct.

Rebuilding the Master Database

The Master database is a system database in SQL Server that contains information about the running server’s configuration. It is essential for the SQL Server to start and function properly. To rebuild the Master database, you can run Setup.exe, verify and repair a SQL Server instance, and rebuild the system databases. This procedure is commonly used to recover from a corrupted installation of SQL Server.

XML Datatype in SQL Server

The XML datatype in SQL Server allows you to store XML documents and fragments in a database. You can create columns and variables of the xml type and store XML instances in them. The xml datatype and associated methods help integrate XML into the relational framework of SQL Server.

Data Compression in SQL Server 2008

Data compression in SQL Server 2008 comes in two flavors: Row Compression and Page Compression. Row compression changes the format of physical storage of data, minimizing the metadata associated with each record. Page compression allows common data to be shared between rows for a given page, using techniques like row compression, prefix compression, and dictionary compression.

DBCC Commands in SQL Server

DBCC commands in SQL Server are Database Console Commands that perform various tasks such as maintenance, information gathering, validation operations, and miscellaneous tasks. These commands are useful for managing and troubleshooting SQL Server databases.

Copying Tables, Schema, and Views in SQL Server

There are multiple ways to copy tables, schema, and views from one SQL Server to another. You can detach the database from one server and attach it to another, manually script all the objects using SQL Server Management Studio (SSMS), or use the SSMS wizard for database transfer.

Finding Tables without Indexes

To find tables without indexes in SQL Server, you can run a simple query using the sys.tables system view. This query will list all the tables that do not have any indexes:

USE <database_name>;
GO

SELECT SCHEMA_NAME(schema_id) AS schema_name, name AS table_name
FROM sys.tables
WHERE OBJECTPROPERTY(OBJECT_ID, 'IsIndexed') = 0
ORDER BY schema_name, table_name;
GO

These are just a few concepts and ideas related to SQL Server. Understanding these concepts can help you effectively manage and optimize your SQL Server databases.

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.