新企业初始化

declare @blue varchar(40);
declare @uid decimal(10,0);
declare @eid int;
declare cur_blue cursor for select EID,DeviceType+’$’+Bluetooth from [EnterpriseBluetooth];
open cur_blue
fetch next from cur_blue into @eid,@blue;
WHILE @@FETCH_STATUS = 0
BEGIN
declare cur_user cursor for select U_ID from [UserEx] where BluetoothAddr like ‘%’+@blue+’%’;
open cur_user
fetch next from cur_user into @uid;
WHILE @@FETCH_STATUS = 0
BEGIN
update [User] set Enterprise_ID=@eid where ID=@uid and (Enterprise_ID is null or Enterprise_ID =0);
fetch next from cur_user into @uid;
END
close cur_user
deallocate cur_user
fetch next from cur_blue into @eid,@blue;
END
close cur_blue
deallocate cur_blue

发表评论