Answer the question
In order to leave comments, you need to log in
How to automatically generate a hash in the field for new lines?
It is necessary to generate a hash for new entries, for example, for 20 characters. I figured out how to do it using the UNIQUEIDENTIFIER data type and the default NEWID () values, but a GUID is generated there. And you need a code shorter and without a dash.
Answer the question
In order to leave comments, you need to log in
short code without dash
SELECT LEFT(REPLACE(CONVERT(varchar(255), NEWID()),'-',''),20)
SELECT dbo.IntToAlpha( 1136572 )
cmrii
CREATE OR ALTER FUNCTION dbo.IntToAlpha ( @IN INT ) RETURNS VARCHAR(16)
WITH EXECUTE AS CALLER
AS
BEGIN
DECLARE @ST VARCHAR(16) = ''
WHILE @IN > 0 BEGIN
SET @ST = CHAR((@IN % 26) + 97 ) + @ST
SET @IN = @IN / 26
END
RETURN @ST
END
--
GO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question