|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, June 10, 2013 7:49 AM
Points: 129,
Visits: 208
|
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Thursday, December 13, 2012 1:38 AM
Points: 693,
Visits: 123
|
|
The first part of the procedure is good enough, but a better solution could be done for the final evaluation. Instead of using a temporary table, we can use output parameters in the sp_executesql procedure, like this: SET @boolExp='SELECT @res=CASE ABS(' + @boolExp + ') WHEN 1 THEN ''TRUE'' ELSE ''FALSE'' END' EXEC sp_executesql @boolExp, N' @res varchar(5) OUTPUT', @res OUTPUTThis way, we replace about 5 lines of code with only 2 and avoid the overhead of using a temporary table. To use the sp_executesql procedure we need to change the type of the @boolExp parameter to nvarchar(300) instead of varchar(300). Razvan PS. The SET NOCOUNT OFF and the DROP TABLE #temp at the end of the procedure are useless (because they are done anyway, automatically). Also useless is the big BEGIN/END block that contains the entire procedure.
|
|
|
|