可以在SELECT语句中直接调用 ? 请赐教

解决方案 »

  1.   

    感谢您使用微软产品。 用户自定义的 functions 是SQL 2000中的新特性, 这有一个简单的例子供您参考: User Defined Functions ====================== User-defined functions, like system functions, can be invoked from a query They also can be executed through an EXECUTE statement like stored procedures. There are also functions like alter function and drop function Simple usage of this new feature: use pubs go drop function User_Defined_fn go -- observer there is no ''()'' after the name of the function create function User_Defined_fn() returns @return_table table(col1 varchar(50), col2 varchar(50), col3 
    varchar(50)) as begin insert @return_table select au_id, au_fname, au_lname from pubs..authors return end go sp_dboption pubs, ''select into'', true go drop table new_table go select * into new_table from user_defined_fn() go -- observe that you can call functions within a SQL Statement - 微软全球技术中心 DTA技术支持 本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。 
      

  2.   

    create function f
    as 
    select a from b where id=1select dbo.f