sql server 年月日时分秒+8位随机数

来源:互联网 发布:软件项目需求文档 编辑:程序博客网 时间:2024/05/16 05:14

一、8位随机数据存储过程

/****** Object:  StoredProcedure [dbo].[pro_rand8]    Script Date: 2015-07-24 12:36:52 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================-- Author:<Author,,Name>-- Create date: <Create Date,,>-- Description:<Description,,>-- =============================================ALTER PROCEDURE [dbo].[pro_rand8](@rand varchar(8)='8888888888888' out)ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from-- interfering with SELECT statements.SET NOCOUNT ON;declare @str varchar(30)set @str=convert(varchar(30),CONVERT(DECIMAL(20,20),rand()))set @rand=SUBSTRING(@str,3,8)   END

二、年月日时分秒+8位随机数
declare @rand varchar(8)execute pro_rand8        @rand=@rand outputselect convert(varchar(19),getdate(),112)+DateName(hour,GetDate())+ DateName(minute,GetDate())+DateName(second,GetDate())+@rand as todayselect DateName(hour,GetDate())+ DateName(minute,GetDate())+DateName(second,GetDate())


0 0
原创粉丝点击