Multiple Inserts in one statement - Row Constructor in SQL Server 2008

Don’t you feel boring sometimes when you have to write an script to insert multiple rows in a table and you do not have any other choice except writing multiple insert statements? In one of my previous posts I showed a way to insert multiple rows by using UNION ALL but wait! there is another [...]

Capture every data operation in SQL Server 2008

Logging all the data related activities to maintain an Audit Trail is always a prime requirement of sensitive applications. People either use Triggers to manage Audit Trails or use middle tiers to maintain the log by themselves.SQL Server 2008 has introduced a completely new framework targeted for Audit Trail maintenance. This framework consists of in-built [...]

100 Nano seconds precision in SQL Server 2008 DATE/TIME data types

Today’s scientist use highly precise instruments and take measurements of time at nano seconds level. This level of precision needs a storage system which can provide storage of time and date data at nano seconds level and can easily scale up with future needs.SQL Server 2008 has introduced a completely updated set of Date and [...]

Represent Trees and Graphs in TSQL by using new data type: HierarchyID

Everyone is talking about SQL Server 2008 these days because it is coming up with lots of enhancements in nearly every area. One of these enhancements is the introduction of a new data type called HierarchyID. This data type is introduced to address one of the typical problem faced by nearly every medium to large [...]

MERGE Statement of SQL Seerver 2008

SQL Server 2008 has introduced a new statement called MERGE which will combine the logic of INSERT-IF NOT EXITS and UPDATE-IF EXISTS.MERGE statement will give you the ability to write one single statement which will update the row if it already exists otherwise it will insert a new row.Additionally, MERGE statement also enable you to [...]

Return Last n Orders by using APPLY operator

With many other new enhancements, SQL Server 2005 has introduced another very useful operator calledAPPLY, which makes life very easy for some complex problems.APPLY operator works as follows:1. It applies a table valued function to each row of the table by using the column values as parameters.2. Resulting rows are then returned [...]

Number padding in TSQL

Sometime we need to pad leading zeros to numeric values so that they can appear having same widthlike 00001,0022,0934 etc. Following code demonstrates the technique to pad leading zeros in front of digits.
–Variable to hold max lengthDeclare @m_maxLength int
–Create a test tableDeclare @m_testTable table (sampleValue int)
–Insert some sample valuesInsert into @m_testTable values (1)Insert into @m_testTable [...]

Microsoft Performance Point Server and Sharepoint Portal Server

Microsoft has announced another server software called “Microsoft Performance Point Server“. According to the information available up till now, this server will act as a bridge between Microsoft Office and SQL Server Business Intelligence architecture. So far so good, but don’t you think it looks similar as what Microsoft promised for SharePoint Server? I [...]

Caching and Recompilation in SQL Server 2005

I was browsing through the newsgroups and found a very interesting white paper link about SQL Server 2005 Plan caching and batch recompilations. This white paper is a must read for anyone who really wants to master the query tuning and optimization strategies.You can read this white paper here

ENABLE/DISABLE all triggers of all tables in one statement

Sometimes we need to disable triggers to perform some tasks. Disabling the trigger by going to each table is very tedious. Following is avery quick way of disabling all triggers on all tables of the given database in a single statement.
sp_msforeachtable “ALTER TABLE ? DISABLE TRIGGER all”
To enable all triggers, you can use following [...]