declare @sql as varchar(max),@ID int=1,@maxID int
WHILE 2155>=1
BEGIN
SELECT @sql= ColumnValue from table where ID=@ID
declare @table1 table(columnvalue2 nvarchar(max),id int IDENTITY(1,1))
insert into @table1(columnvalue2)
exec (@sql )
update table set ColumnValue=isnull(b.columnvalue2,'') FROM table a jOIN
@table1 b ON a.Id=b.id
SET @ID=@id+1
END
SELECT distinct CID,Name,sorder,Locations,columnValue FROM table where isActive = 1 order by Locations,CID,Name
当我执行上述条件时它显示超时。可以为查询超时的任何一个帮助吗?
答案 0 :(得分:0)
首先,SET @maxID = <some value>
然后,将WHILE 2155>=1
更改为WHILE @ID<=@maxID
,否则您的循环将永远不会结束......