create proc p_GetRegTables
@AllTables varchar(510) output --01 到ff 个tableID
as
/*
获得所有注册的tableID
-1 没有满足条件的记录
0 成功
*/
begin
if not exists(select *from nameserver where terminate_type=1)
return -1
set @AllTables=''
begin transaction
declare @iTable tinyint
declare @table varchar(2)
declare cursor_table cursor for
select distinct table_id from NameServer
open cursor_table
if @@cursor_rows=0
begin
close cursor_table
deallocate cursor_table
commit transaction
return 0
end
fetch next from cursor_table into @iTable
while @@fetch_status=0
begin
exec p_TinyintToHex @iTable,@table output --255->FF
set @AllTables=@AllTables+@table
fetch next from cursor_table into @iTable
end