SQLServer生成随机UUID

创建生成随机UUID的函数 FunGetUUID32

CREATE FUNCTION [dbo].[FunGetUUID32](@newid varchar(36))  
RETURNS VARCHAR(32)  
AS  
BEGIN  
    DECLARE @id VARCHAR(32);  
  
    select @id=SUBSTRING(@newid,1,8)+SUBSTRING(@newid,10,4)+SUBSTRING(@newid,15,4)+ SUBSTRING(@newid,20,4)+SUBSTRING(@newid,25,12)  
  
    RETURN @id    
END 

使用方法

select dbo.[FunGetUUID32](NEWID());
打开支付宝首页搜索“515750224”,即可领取红包

标签: SQLServer

添加新评论