IDENT_CURRENT IDENT_CURRENT - 北京怡康軟件科技有限公司 資源網(wǎng) "/>

精品国产亚洲一区二区三区,男女作爱在线观看免费网站,欧美的又大又长做禁片A片,97国产精品人妻无码久久久

  • 相關(guān)軟件
    >IDENT_CURRENT 創(chuàng)建者:webmaster 更新時(shí)間:2006-02-16 15:51

    返回為任何會(huì)話和任何作用域中的指定表最后生成的標(biāo)識(shí)值。



    語(yǔ)法


    IDENT_CURRENT('table_name')



    參數(shù)


    table_name



    是將要返回其標(biāo)識(shí)值的表的名稱。table_name 的數(shù)據(jù)類型為 varchar,沒有默認(rèn)值。



    返回類型


    sql_variant



    注釋


    IDENT_CURRENT 類似于 Microsoft® SQL Server™ 2000 標(biāo)識(shí)函數(shù) SCOPE_IDENTITY 和 @@IDENTITY。這三個(gè)函數(shù)都返回最后生成的標(biāo)識(shí)值。但是,它們?cè)诙x"最后"的作用域和會(huì)話上不同。


    • IDENT_CURRENT 返回為任何會(huì)話和任何作用域中的特定表最后生成的標(biāo)識(shí)值。



    • @@IDENTITY 返回為當(dāng)前會(huì)話的所有作用域中的任何表最后生成的標(biāo)識(shí)值。



    • SCOPE_IDENTITY 返回為當(dāng)前會(huì)話和當(dāng)前作用域中的任何表最后生成的標(biāo)識(shí)值。



    示例


    下面的示例說明由 IDENT_CURRENT、@@IDENTITY 和 SCOPE_IDENTITY 返回的不同的標(biāo)識(shí)值。



    USE pubs
    DROP TABLE t6
    DROP TABLE t7
    GO
    CREATE TABLE t6(id int IDENTITY)
    CREATE TABLE t7(id int IDENTITY(100,1))
    GO
    CREATE TRIGGER t6ins ON t6 FOR INSERT
    AS
    BEGIN
      INSERT t7 DEFAULT VALUES
    END
    GO
    --end of trigger definition

    SELECT   * FROM t6
    --id is empty.

    SELECT   * FROM t7
    --id is empty.

    --Do the following in Session 1
    INSERT t6 DEFAULT VALUES
    SELECT @@IDENTITY    
    /*Returns the value 100, which was inserted by the trigger.*/

    SELECT SCOPE_IDENTITY()  
    /* Returns the value 1, which was inserted by the
    INSERT stmt 2 statements before this query.*/

    SELECT IDENT_CURRENT('t7')
    /* Returns value inserted into t7, i.e. in the trigger.*/

    SELECT IDENT_CURRENT('t6')
    /* Returns value inserted into t6, which was the INSERT statement 4 stmts before this query.*/

    -- Do the following in Session 2
    SELECT @@IDENTITY
    /* Returns NULL since there has been no INSERT action
    so far in this session.*/

    SELECT SCOPE_IDENTITY()
    /* Returns NULL since there has been no INSERT action
    so far in this scope in this session.*/

    SELECT IDENT_CURRENT('t7')
    /* Returns the last value inserted into t7.*/
    相關(guān)文章
    本頁(yè)查看次數(shù):