【问题标题】:Is there a way to generate a Unique Identifier (in SQL Server newid()) in Excel 2007有没有办法在 Excel 2007 中生成唯一标识符(在 SQL Server newid() 中)
【发布时间】:2009-08-26 14:40:07
【问题描述】:

您能否在 Excel 2007 中创建一个唯一标识符。我正在寻找由 SQL Server 函数 newid() 生成的相同值。

谢谢

【问题讨论】:

    标签: sql-server excel


    【解决方案1】:

    你可以使用CoCreateGuid API函数

    Declare Function CoCreateGuid Lib "ole32" (ByRef GUID As Byte) As Long
    
    Public Function CreateGUID()
       Dim ID(0 To 15) As Byte
       Dim N As Long
       Dim GUID As String
       Dim Res As Long
       Res = CoCreateGuid(ID(0))
       For N = 0 To 15
          GUID = GUID & IIf(ID(N) < 16, "0", "") & Hex$(ID(N))
       Next N
       CreateGUID = GUID
    End Function
    

    【讨论】:

    • 感谢您的回答。这是完美的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    相关资源
    最近更新 更多