Constraints… helpful in making sure you get the data you want out of your database! Constraints allow you to define rules that the data must follow in order to be inserted into a record. You might want to define a primary key or foreign key in order to define the relationship of two related records…
Category: Microsoft SQL
Extract, Transform, and Load
What is ETL? ETL stands for Extract, Transform and Load, a process used to collect data from various sources, transform the data depending on business rules and load the data into a destination database. The need to use ETL arises from the fact that in modern computing business data resides in multiple locations and in…
Triggers
Triggers are one of the most misunderstood features in Microsoft SQL server. Most of that misunderstanding comes from people implementing triggers with little understanding to their impact. Even worse, they’ll implement them without testing. And the worst of all, not using them, when the functionality being requested is the very definition of what a trigger…
Exception Handling
Learning to handle errors better can be one of the skills that will really set you apart from other SQL Developers. You can do constant unit testing after each change, but odds are you’ll never hit ever scenario your code will face. There is a better way. If you have programmed in any language like…
New Sample Databases for 2005!
Back when we were all using SQL 2000, I shared a link to download SQL 2000 demo databases. Now, most of us are on SQL 2005, we need a new database to work with. Microsoft was kind enough to oblige, so here it is! The link below will let you download sample databases for your…
Default Values
When you start creating tables and setting them so they can’t have NULL values, you’ll eventually need a way to define a default value for the column. A default value is one that a column would apply to its record if a value is not provided. To specify the default value in a SQL statement,…
Identity Columns
An IDENTITY column is a column that automatically gets it’s value set by the database engine when a new record is added. This is one of the oldest ways Microsoft SQL has of making sure a record is unique. Even if a user were to insert the same record twice, the IDENTITY will always be…
Computed Columns
What is a Computed Column A computed column is a column that users will not enter data for, but the SQL Server will compute and store a value in. The expression for a computed column may include the names of other columns in the table. These columns can also be combined with literal values and…
Schema
In previous versions of SQL Server we had what we called “owners” of objects. Nearly every time you talked about an object “owner” you were talking about dbo. Think about the default name of any user defined functions you created. They always got “dbo.” added to the beginning of their name by the engine when…
NULL Values, Blank Values, and Table Design
Have you dealt with NULL yet? A field is referred to as NULL if it has not received a value. To specify the NULL-ability of a column using T-SQL, just add NULL after the datatype for the column. To specify that values are required, add NOT NULL. If you don’t specify NULL or NOT NULL,…