zoukankan      html  css  js  c++  java
  • sql2008 hierarychyid parse

    Parse (Database Engine)

    Parse converts the canonical string representation of a hierarchyid to a hierarchyid value. Parse is called implicitly when a conversion from a string type to hierarchyid occurs. Acts as the opposite of ToStringParse() is a static method.

     
    -- Transact-SQL syntax
    hierarchyid::Parse ( input )
    -- This is functionally equivalent to the following syntax 
    -- which implicitly calls Parse():
    CAST ( input AS hierarchyid )
     
    -- CLR syntax
    static SqlHierarchyId Parse ( SqlString input ) 
    input

    Transact-SQL: The character data type value that is being converted.

    CLR: The String value that is being evaluated.

    SQL Server return type: hierarchyid

    CLR return type: SqlHierarchyId

    If Parse receives a value that is not a valid string representation of a hierarchyid, an exception is raised. For example, if char data types contain trailing spaces, an exception is raised.

    A. Converting Transact-SQL values without a table

    The following code example uses ToString to convert a hierarchyid value to a string, and Parse to convert a string value to a hierarchyid.

     
    DECLARE @StringValue AS nvarchar(4000), @hierarchyidValue AS hierarchyid
    SET @StringValue = '/1/1/3/'
    SET @hierarchyidValue = 0x5ADE
    
    SELECT hierarchyid::Parse(@StringValue) AS hierarchyidRepresentation,
     @hierarchyidValue.ToString() AS StringRepresentation ;
    GO

    Here is the result set.

    hierarchyidRepresentation StringRepresentation

    ------------------------- -----------------------

    0x5ADE /1/1/3/

    B. CLR example

    The following code snippet calls the Parse() method:

     
    string input = “/1/2/”;
    SqlHierarchyId.Parse(input);
  • 相关阅读:
    词频统计
    时事点评-红芯浏览器事件
    我的第一篇博客
    浏览器同源策略,及跨域解决方案
    进击的 JavaScript (八) 之 继承
    进击的 JavaScript (七) 之 原型链
    进击的 JavaScript(五) 之 立即执行函数与闭包
    进击的 JavaScript(六) 之 this
    进击的 JavaScript(四) 之 闭包
    进击的 JavaScript(三) 之 函数执行过程
  • 原文地址:https://www.cnblogs.com/wucg/p/2229859.html
Copyright © 2011-2022 走看看