use pubs 
go
create function salesbystore(@storeid varchar(30))
returns table
as
return(select title,qty  from sales s ,titles t where s.stor_id=@storeid and t.title_id=s.title_id)
这个自定义函数的意思是什么? 怎么调用? 自定义函数的存放位置在哪儿?

解决方案 »

  1.   

    改函数返回一个表,
    调用方式   select * from salesbystore('storeid ')   storeid为传入参数 
      

  2.   

    1、传入一个参数storeid ,返回一个表
    2、调用方式 select * from salesbystore('storeid')
    3、存放在数据库->可编程性->函数->表值函数
      

  3.   

    这个自定义函数的意思是什么?-->返回一个表怎么调用?--> select * from dbo.salesbystore('参数')自定义函数的存放位置在哪儿?-->函数-->dbo.salesbystore
      

  4.   

    返回查询
    select title,qty from sales s ,titles t where s.stor_id=@storeid and t.title_id=s.title_id
    的结果
      

  5.   

    Sql server表值函数
    关键字: sql server, 表值函数Sql server 的表值函数是返回一个Table类型,table类型相当与一张存储在内存中的一张虚拟表。
    实现表值函数很简单:
    下面是一个不带输入参数的表值函数create function tvpoints()
    returns table
    as 
    return
    (
    select * from tb_users
    );
    这个表值函数数查询所有用户表的数据对于多语句表值函数,在 BEGIN...END 语句块中定义的函数体包含一系列 Transact-SQL 语句,这些语句可生成行并将其插入将返回的表中。以下示例创建了一个表值函数.create function tvpoints()
    returns @points table (x float, y float)
    as begin
    insert @points values(1,2);
    insert @points values(3,4);
    return;
    end  查询表值函数跟查询普通表一样
    select * from tvpoints()
    返回的是一张表  带输入参数的表值函数create function tvpoints2(@x AS int,@y as int)
    returns @points table (x float, y float)
    as begin
    insert @points values(@x,@y);
    return;
    end
      

  6.   

    传入一个参数storeid ,返回一个结果集