My question is about using Types in SQL Server 2008. Will my new attempt at updating a table using functions be much faster by using Types? New attempt described below:
I'm building a stored procedure that returns a result set with any number of columns. The columns in the result depend on arguments passed when calling the procedure.
Some of the columns I add to the temp table while building the result to be returned are based on the result of a function. Normally with SQL Server I'd write a statement such as:
UPDATE MyTable SET NewColumn = f_GetNewColumValue(MyTable.PrimaryKeyField)
but I've seen in SQL Server 2008 I can pass a TYPE to a function, which lets me write something like
UPDATE MyTable SET NewColumn = NewColumnValue FROM MyTable LEFT JOIN f_GetNewColumValue(@Keys) ncv ON ncv.PrimaryKeyField = MyTable.PrimaryKeyField
where @Keys is a type I pre-defined with 1 column for the primary key field.
I assumed this would be quicker. Will my new attempt at updating a table using functions be much faster by using Types?