我定义的sqlserver自定义函数为: 
CREATE function f_str(@date_from datetime) 
returns varchar(100) 
as 
begin 
    declare @sql varchar(5000) 
    select @sql=isnull(@sql+',','')+ltrim(t_date) from t_tariff where t_jfdate>@date_from 
    return @sql 
end 
其中f_str函数由一个变量:@date_from。 
======================================================== 
asp程序调用: <% 
dim date_from 
date_from = "2009-1-1" 
dim sql 
sql="select dbo.f_str('"& date_from &"') from t_xx" 
rs.open sql,conn,1,3 %> 我执行却不出现我想要的结果啊!请教大家! 

解决方案 »

  1.   

    返回字符串就不用from表了。。
    sql="select dbo.f_str('"& date_from &"') from t_xx" 
    ---->
    sql="select dbo.f_str('"& date_from &"')"
      

  2.   

    select @sql=isnull(@sql+',','')+ltrim(t_date) from t_tariff where t_jfdate>@date_from 
    这里的t_date是什么类型的?datetime型的转换下格式
    select @sql=isnull(@sql+',','')+convert(char(10),t_date,120) from t_tariff where t_jfdate>@date_from 
      

  3.   

    你在sql中调试一下就知道了
     
     select @sql=isnull(@sql+',','')+ltrim(t_date) from t_tariff where t_jfdate>@date_from 
      

  4.   

    问题主要出现在t_jfdate>@date_from 这个地方。好像日期格式不对。
      

  5.   

    你传入的是日期格式是可以比较的!不然你不会得到数据,你是要查询传入日期(@data_from)之前的还是传入日期之后的?
      

  6.   

    where datediff(day,t_jfdate,@date_from )<0
      

  7.   

    不懂asp
    参数也改为字符好了
    函数里面转换为datetime