`

循环车号,判断以车号为表名的表是否存在

 
阅读更多

 

 

--循环车号,判断以车号为表名的表是否存在
DECLARE @vehiclenum varchar(20);
DECLARE @vehicletablename varchar(100);
declare  VEH_Cursor CURSOR FOR select vehicle_num from vehicle;
open VEH_Cursor	
fetch next from VEH_Cursor into @vehiclenum
	while @@FETCH_STATUS=0
	begin
	SET @vehicletablename = '['+@vehiclenum+']';
	--print @vehicletablename;
	if object_id(@vehicletablename) is null  
        print @vehicletablename+' is not exist';
fetch next from VEH_Cursor into @vehiclenum
	end
	close VEH_Cursor
	deallocate   VEH_Cursor

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics