| A SQL Server Leap Year Test Function Transact-SQL does not provide a standard function that allows developers to determine if a year is a leap year. This article describes two functions. One to calculate the number of days in a year and one that utilises the result to identify leap years. |
| SQL Server Numeric Formatting Transact-SQL includes the Convert command that allows values to be converted between differing data types. When converting some numeric types to text, a style code may be applied. This code determines the formatting of the generated string. |
| Hiding the SQL Server sa Login When SQL Server is installed, the "sa" login is created automatically. When using Windows-only authentication, this administrative account is disabled. With mixed mode authentication, the "sa" login can be a target for attacks. |
| Disabling SQL Server Triggers Triggers can be applied to the tables in a SQL Server database so that actions are taken automatically when data is inserted, updated or deleted. In some situations it is necessary to disable triggers to allow data to be modified without their effects. |
| Disabling SQL Server Table Constraints SQL Server databases should be configured with foreign key constraints to maintain referential integrity and check constraints to ensure that table data is always valid. Occasionally these constraints can be a hindrance and may be temporarily disabled. |
| Inserting Only Table Defaults in SQL Server Some SQL Server database tables are designed with a default value or an identity specification for every column. If a row in such a table must only use the default values, a special syntax is required to allow an INSERT to be executed. |
| T-SQL INSERT INTO SELECT and SELECT INTO A common task when using Transact-SQL (T-SQL) is to copy information from one table into another, possibly changing the data or its structure in the same operation. This can be achieved by combining the standard SELECT and INSERT commands. |
| SQL Server Error Handling Microsoft SQL Server 2005 introduced new error handling capabilities for scripts and stored procedures. This article describes the use of the try / catch block in Transact-SQL that permits errors to be captured and allows for graceful recovery. |
| Obtaining the Last Inserted Identity in SQL Server SQL Server identity columns allow a sequence of numbers to be generated so that a unique number can be applied for each new row in a table. As these values are produced automatically, it is sometimes necessary to retrieve an identity after creation. |
| Allowing Table Re-Creation in SQL Server 2008 SQL Server 2008 introduced a new default setting that prevents changes being made to the schema if those modifications would require a table to be dropped and recreated. This article explains how to change the default option. |