Dear Friends,
SQL Server compute scalar operator performs a scalar computation and returns computed value. This calculation can be as simple as conversion of value or could be concatenation of value. Most of the times, this operator represents minimal cost as compared to the execution plan and hence overlooked. It is recommended to have a proper look when we are dealing with complex loops, cursors and if we are experiencing CPU bottlenecks.
Let us take a look into this operator using simple query statement.
USE [AdventureWorks2012] DECLARE @Table TABLE(ID SmallInt PRIMARY KEY) SELECT 'SQLServerGeeks' + '.' + 'Com' FROM @Table
To understand Expr1003, let us decode query plan in text.
USE [AdventureWorks2012] --Step1 SET SHOWPLAN_TEXT ON --Step2 DECLARE @Table TABLE(ID SmallInt PRIMARY KEY) SELECT 'SQLServerGeeks' + '.' + 'Com' FROM @Table --Step3 SET SHOWPLAN_TEXT OFF
The plan generated using compute scalar simply did the concatenation between ‘SQLServerGeeks’, ‘.’ and ‘com’. We are going to discuss more on this operator tomorrow, stay tuned.
Happy learning!
Regards,
Kanchan
Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook | Follow me on Twitter | Follow me on FaceBook