Hello all,
I have the stored procedure:
CREATE PROCEDURE UniqueID
@szTableName varchar(20),
@szPrefix varchar(10),
@szKeyword varchar(20),
@szUID varchar(20) output
AS
declare @nCount smallint
declare @nLen smallint
declare @szTmp varchar(20)
select @nCount = count(*) from @szTableName
cont:
if (@nCount = 0)
set @nCount = 1
set @szTmp = cast(@nCount as varchar(20))
set @nLen = len(@szTmp)
while (@nLen < 6)
begin
set @szTmp = '0' + @szTmp
set @nLen = len(@szTmp)
end
set @szUID = @szPrefix + @szTmp
-- Test if this value existed
select @nCount = count(*) from @szTableName where @szKeyword = @szUID
if (@nCount > 0)
begin
select @nCount = count(*) from @szTableName
set @nCount = @nCount + 1
goto cont
end
When I check syntax, it always show the error: "Must declare the variable: @szTableName"
Please show me the way to correct this error.
Thanks for you help.
I have the stored procedure:
CREATE PROCEDURE UniqueID
@szTableName varchar(20),
@szPrefix varchar(10),
@szKeyword varchar(20),
@szUID varchar(20) output
AS
declare @nCount smallint
declare @nLen smallint
declare @szTmp varchar(20)
select @nCount = count(*) from @szTableName
cont:
if (@nCount = 0)
set @nCount = 1
set @szTmp = cast(@nCount as varchar(20))
set @nLen = len(@szTmp)
while (@nLen < 6)
begin
set @szTmp = '0' + @szTmp
set @nLen = len(@szTmp)
end
set @szUID = @szPrefix + @szTmp
-- Test if this value existed
select @nCount = count(*) from @szTableName where @szKeyword = @szUID
if (@nCount > 0)
begin
select @nCount = count(*) from @szTableName
set @nCount = @nCount + 1
goto cont
end
When I check syntax, it always show the error: "Must declare the variable: @szTableName"
Please show me the way to correct this error.
Thanks for you help.