有关存储过程和用户​​定义功能的问题 [英] question about stored Procedure and User-definde function

查看:70
本文介绍了有关存储过程和用户​​定义功能的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是存储过程和用户​​定义函数以及它们在sql server 2005中的区别?

what are the stored Procedure and User-definde function and difference between them in sql server 2005

推荐答案

用于创建存储函数的方法首先单击数据库->可编程性->函数->表值函数或sclar值函数,然后右键单击并根据需要选择新的标量值或表值函数.
例如:->
for creating stored function first click on database -> programmability->function->table-value functions or sclar-valued functions then right click and select new scalr-value or table-value function as you want.
example:->
--select * from DatabaseName.dbo.split('CON,CON1,CON2',',')
Create FUNCTION [dbo].[Split](@String varchar(max), @Delimiter char(1))
returns @temptable TABLE (items varchar(max))
as
begin
    declare @idx int
    declare @slice varchar(max)

    select @idx = 1
        if len(@String)<1 or @String is null  return

    while @idx!= 0
    begin
        set @idx = charindex(@Delimiter,@String)
        if @idx!=0
            set @slice = left(@String,@idx - 1)
        else
            set @slice = @String

        if(len(@slice)>0)
            insert into @temptable(Items) values(@slice)

        set @String = right(@String,len(@String) - @idx)
        if len(@String) = 0 break
    end
return
end


此函数的工作方式类似于字符串的拆分函数.
有关更多信息,请参见存储过程与函数之间的差异 [ ^ ]


this function work like split functon of string.
for more look at Differences between Stored Procedures and Functions[^]


我认为您需要了解一些基础知识
//存储过程
http://msdn.microsoft.com/en-us/library/ms190782.aspx

//功能
http://msdn.microsoft.com/en-us/library/ms186755.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms174318.aspx [ ^ ]
I think you need to know some basics
//Store procedure
http://msdn.microsoft.com/en-us/library/ms190782.aspx

//Functions
http://msdn.microsoft.com/en-us/library/ms186755.aspx[^]
http://msdn.microsoft.com/en-us/library/ms174318.aspx[^]


这篇关于有关存储过程和用户​​定义功能的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆