zoukankan      html  css  js  c++  java
  • 一个级联关系的表,向上获取各个字段名的函数

    代码
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    --
     Author:        
    --
     Create date: 
    --
     Description:    返回地区的级联表示,如: 广东 -- 深圳 -- 龙岗
    --
     =============================================
    ALTER FUNCTION [dbo].[getAreaName] 
    (
        
    -- Add the parameters for the function here
        @fareacode numeric(18,0)
    )
    RETURNS varchar(200)
    AS
    BEGIN
        
    declare @returnName varchar(200-- 返回字符串
        declare @nextAreaCode numeric(180)
        
    declare @tempName varchar(200-- 临时存放名称
        
        
    set @tempName = ''
        
    set @returnName = ''

        
    set ANSI_NULLS OFF

        
    select @tempName = fareaname, @nextAreaCode = fparentcode from tbarea where fareacode = @fareacode
        
    set @returnName = @tempName

        
    while (@nextAreaCode <> -1)
        
    begin
            
    select @tempName = fareaname, @nextAreaCode = fparentcode from tbarea where fareacode = @nextAreaCode
            
    set @returnName = @tempName + ' -- ' + @returnName
        
    end

        
    set ANSI_NULLS ON
        
    return @returnName
    END

    走向地狱的途中,不小心走了程序员这条路,路上一个个黑心的老板,和暗无天日的加班,我才发现,通往地狱的路径中,我们这行是最短的。

  • 相关阅读:
    举个手问个问题;
    c++字符串详解(转)
    Glide请求图片能携带Cookie的哟!
    Glide加载异常调试
    Notification中使用Glide
    manifest中读取<meta-data>
    Glide 魔法般的自定义扩展
    服务端报错死循环,无法输出错误页面问题
    android必须要进行为不同分辨率设备切图
    TextView无法通过setText设值
  • 原文地址:https://www.cnblogs.com/zlfucku/p/1689236.html
Copyright © 2011-2022 走看看