Question : constant scan in execution plan

I have found a constant scan in my execution plan. Can someone tell me under what condition a constant scan would happen.

Answer : constant scan in execution plan

Its not that you will obtain a Constant Scan when you use a partitioned table.

From MSDN,

Constant Scan

The Constant Scan logical and physical operator introduces a constant row into a query. It will return either zero or one row, which usually contains no columns. A Compute Scalar operator is often used to add columns to the row produced by a Constant Scan.

When you add a new column to a row / Result set using a Scalar function, then you will have a Constant Scan.

Say you have a function named dbo.format and if you use it in your query like

SELECT col1, col2, dbo.format(col3)
FROM urtable

It will have a constant scan.

Whenever you have a scalar function in your query to return some value, For eg, GETDATE() as mentioned earlier, SUBSTRING, LEN, CONVERT, CAST
You will end up in a constant scan.
Random Solutions  
 
programming4us programming4us