我们新建一个DataBase project,然后建立一个UserDefinedFunctions,Code像这样:
<div class="codetitle"><a style="CURSOR: pointer" data="47900" class="copybut" id="copybut47900" onclick="doCopy('code47900')"> 代码如下:
我们新建一个DataBase project,然后建立一个UserDefinedFunctions,Code像这样:
<div class="codetitle"><a style="CURSOR: pointer" data="47900" class="copybut" id="copybut47900" onclick="doCopy('code47900')"> 代码如下:
我们来看它的Client Statistic:
接着我们执行测试T-sql使用相同的array:
CTE实现的Split function的Client statistic:
通过对比,你可以发现CLR的performance略高于CTE方式,原因在于CLR方式有Cache功能,并且把一个复杂的运算放到程序里比DataBase里更加高效。
您还可以参考:
ssthandot.com/index.PHP/DataMgmt/DBProgramming/split-string-in-sql-server-2005-clr-vs-t">Split string in sql Server 2005+ CLR vs. T-sql
Author:Petter Liu