有没有办法在Excel 2007中生成唯一标识符(在SQL Server newid()中)

时间:2009-08-26 14:40:08

标签: sql-server excel

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

由于

1 个答案:

答案 0 :(得分:3)

您可以使用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