zoukankan      html  css  js  c++  java
  • SQLServer 表值函数与标量值函数 定义方式与调用区别

    标量值函数创建:

    Create Function [dbo].[GoosWidth](@GoodsCode varchar(20))
    Returns float
    Begin
           Declare @Value float
           Select @Value = GoodsWidth From Master_Goods Where GoodsCode = @GoodsCode
           Return(@Value)
    End

    表值函数创建:

    Create Function [dbo].[GetAllGoods]()
    Returns Table
    As
     Return(Select * From [Master_Goods])

    创建一个自定义样式的标量函数

    Create Function [dbo].[GetMyStyleDate](@Date DateTime)
    Returns nvarchar(20)
    Begin
           Declare @ReturnValue nvarchar(20)
           Set @ReturnValue = '今天是' + convert(nvarchar(4),datepart(year,@Date)) + '年'
                                                     + convert(nvarchar(2),datepart(month,@Date)) + '月'
                                                     + convert(nvarchar(2),datepart(day,@Date)) + '日'
           return @ReturnValue
    End

    其中标量值函数调用的时候方式如下:Select dbo.GoosWidth('0003')    注意:函数前边一定要加上所有者:dbo

    表值函数调用方法如下:Select * From GetAllGoods()       表值函数调用的时候不用加入。

  • 相关阅读:
    (项目)在线教育平台(九)
    (项目)在线教育平台(八)
    界面渐变特效 -- CSS实现 -- 兼容IE8
    固定背景图片铺满浏览器窗口
    时间连带上下午
    慢显示动画
    CSS强制英文、中文换行与不换行 强制英文换行
    html5 标签在 IE 下使用
    html5 兼容版本 video
    添加到收藏夹
  • 原文地址:https://www.cnblogs.com/yangyang8848/p/1514493.html
Copyright © 2011-2022 走看看