Category Archives: SQL Server 2008

Coalesce in SQL Server

The Many Uses of Coalesce in SQL Server. SELECT COALESCE(NULL, NULL, NULL, GETDATE()) Using Coalesce to Pivot If you run the following statement against the AdventureWorks database SELECT Name FROM HumanResources.Department WHERE (GroupName = ‘Executive General and Administration’) DECLARE @DepartmentName VARCHAR(1000) SELECT @DepartmentName = COALESCE(@DepartmentName,”) + Name + ‘;’ FROM HumanResources.Department WHERE (GroupName = ‘Executive General and Administration’) SELECT @DepartmentName AS DepartmentNames and get the following result set. kill all the … Continue reading

Posted in SQL Server 2008 | Leave a comment

sqlcmd Utility (SQL Server 2008 R2)

sqlcmd Utility. The sqlcmd utility lets you enter Transact-SQL statements, system procedures, and script files at the command prompt, in Query Editor in SQLCMD mode, in a Windows script file or in an operating system (Cmd.exe) job step of a … Continue reading

Posted in SQL Server 2008 | Leave a comment

Filtered Index Design Guidelines

Filtered Index Design Guidelines A filtered index is an optimized nonclustered index, especially suited to cover queries that select from a well-defined subset of data. It uses a filter predicate to index a portion of rows in the table. A … Continue reading

Posted in SQL Server 2008 | Leave a comment