CREATE PROCEDURE GetHashCode
@input tAppName,
@hash INT OUTPUT
AS
/*
This sproc is based on this C# hash function:
int GetHashCode(string s)
{
int hash = 5381;
int len = s.Length;
for (int i = 0; i < len; i++) {
int c = Convert.ToInt32(s[i]);
hash = ((hash << 5) + hash) ^ c;
}
return hash;
}
However, SQL 7 doesn't provide a 32-bit integer
type that allows rollover of bits, we have to
divide our 32bit integer into the upper and lower
16 bits to do our calculation.
*/
DECLARE @hi_16bit INT
DECLARE @lo_16bit INT
DECLARE @hi_t INT
DECLARE @lo_t INT
DECLARE @len INT
DECLARE @i INT
DECLARE @c INT
DECLARE @carry INT
SET @hi_16bit = 0
SET @lo_16bit = 5381
SET @len = DATALENGTH(@input)
SET @i = 1
WHILE (@i <= @len)
BEGIN
SET @c = ASCII(SUBSTRING(@input, @i, 1))
/* Formula:
hash = ((hash << 5) + hash) ^ c */
/* hash << 5 /
SET @hi_t = @hi_16bit * 32 / high 16bits << 5 /
SET @hi_t = @hi_t & 0xFFFF / zero out overflow */
SET @lo_t = @lo_16bit * 32 /* low 16bits << 5 */
SET @carry = @lo_16bit & 0x1F0000 /* move low 16bits carryover to hi 16bits /
SET @carry = @carry / 0x10000 / >> 16 /
SET @hi_t = @hi_t + @carry
SET @hi_t = @hi_t & 0xFFFF / zero out overflow */
/* + hash /
SET @lo_16bit = @lo_16bit + @lo_t
SET @hi_16bit = @hi_16bit + @hi_t + (@lo_16bit / 0x10000)
/ delay clearing the overflow */
/* ^c */
SET @lo_16bit = @lo_16bit ^ @c
/* Now clear the overflow bits */
SET @hi_16bit = @hi_16bit & 0xFFFF
SET @lo_16bit = @lo_16bit & 0xFFFF
SET @i = @i + 1
END
/* Do a sign extension of the hi-16bit if needed */
IF (@hi_16bit & 0x8000 <> 0)
SET @hi_16bit = 0xFFFF0000 | @hi_16bit
/* Merge hi and lo 16bit back together /
SET @hi_16bit = @hi_16bit * 0x10000 / << 16 */
SET @hash = @hi_16bit | @lo_16bit
RETURN 0
GO
消息 2715,级别 16,状态 3,过程 GetHashCode,第 1 行
第 1 个列、参数或变量: 找不到数据类型 tAppName。
参数或变量 '@input' 的数据类型无效。
请问SQLSERVER 中没有这样的tAppName数据类型的我的,这个存储过程该怎么建立。