sql Созданиерандомногословаизрусскихбуквзаданнойдлины

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Созданиерандомногословаизрусскихбуквзаданнойдлины相关的知识,希望对你有一定的参考价值。

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Куракин В.А.
-- Create date: 27.10.2016
-- Description:	Создание рандомного слова из русских букв заданной длины
-- =============================================
CREATE PROCEDURE usp_GetRandomWord
	@letterCounr int = 10
AS
BEGIN
	DECLARE 
	@i int,
	@min bigint, @max bigint, @rand as bigint,
	@onechar1 nvarchar(1), @onechar2 nvarchar(1), @return nvarchar(255)
	

	Set @return = ''	

	SELECT @min = 1, @max = 33

	set @i = 0

	while (@i < @letterCounr)
	BEGIN

		while (@onechar1 is null)
		begin
			SELECT @rand = ((@max + 1) - @min) * Rand() + @min 
			select @onechar1 = [letter] from [PDGP].[dbo].[Letter]
			where ID = @rand and isHard = 0 and isvocular = 0
		end

		set @return = @return + @onechar1
		set @i = @i + 1

		while (@onechar2 is null)
		begin
			SELECT @rand = ((@max + 1) - @min) * Rand() + @min 
			select @onechar2 = [letter] from [PDGP].[dbo].[Letter]
			where ID = @rand and isHard = 0 and isvocular = 1
		end

		set @return = @return + @onechar2
		set @i = @i + 1

		set @onechar1 = null
		set @onechar2 = null
	END

	select @return
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Куракин В.А.
-- Create date: 27.10.2016
-- Description:	Создание рандомного слова из русских букв заданной длины
-- =============================================
CREATE PROCEDURE [dbo].[usp_GetRandomWord]
(
	@letterCount int = 10
	, @out nvarchar(10) output
)
AS
BEGIN
	DECLARE 
	@i int,
	@min bigint, @max bigint, @rand as bigint,
	@onechar1 nvarchar(1), @onechar2 nvarchar(1), @return nvarchar(255)
	

	Set @return = ''	

	SELECT @min = 1, @max = 33

	set @i = 0

	while (@i < @letterCount)
	BEGIN

		while (@onechar1 is null)
		begin
			SELECT @rand = ((@max + 1) - @min) * Rand() + @min 
			select @onechar1 = [letter] from [PDGP].[dbo].[Letter]
			where ID = @rand and isHard = 0 and isvocular = 0
		end

		set @return = @return + @onechar1
		set @i = @i + 1

		while (@onechar2 is null)
		begin
			SELECT @rand = ((@max + 1) - @min) * Rand() + @min 
			select @onechar2 = [letter] from [PDGP].[dbo].[Letter]
			where ID = @rand and isHard = 0 and isvocular = 1
		end

		set @return = @return + @onechar2
		set @i = @i + 1

		set @onechar1 = null
		set @onechar2 = null
	END
	
	set @out = @return
END

以上是关于sql Созданиерандомногословаизрусскихбуквзаданнойдлины的主要内容,如果未能解决你的问题,请参考以下文章

Erlangе демо

python Высотадеревазадонногочислами

html 搜索引擎优化标题。 ДелаемТВ-параметр[[* seoTitle]]。 Еслидлястраницыонзаполнен,тогдавыводимего,аеслинет,т

php обрезаемпоследнююбукву - делаемизмножественногочислаединственное

Айтжан То?та?ан - К?й деген?м?з шоу емес

javascript Возвратслучайногочиславзаданномдиапазоне