以前都是在代码中生成GUID值,然后保存到数据库中去,今天发现用sql也能生成GUID值,觉得很新奇,所以记下来。

sellect newid();  //得到的即为GUID值

此sql内置函数返回的数据类型为:uniqueidentifier

打印转换后的值:

DECLARE @myid uniqueidentifier
SET @myid = NEWID()
PRINT 'Value of @myid is: '+ CONVERT(varchar(255), @myid)

相关文章:

  • 2021-09-16
  • 2021-10-16
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-06-19
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案