Thanks all for the input, the security issue was resolved by using dropdownlists for the coulmn, operator, and value arguments so the user is limited to those lists to create...
I have tried every combinantion of ANSI_NULLS and ANSI_WARNINGS. And am still getting the same error. I am running this script from QueryAnalyser. Once it create the function and SP...