表结构
Id int Unchecked
Title nvarchar(50) Checked
Value nvarchar(1000) Checked
Remark nvarchar(1000) Checked
查询
DECLARE @temp TABLE ( Id INT, Title nvarchar(50), Value nvarchar(1000), Remark nvarchar(1000), Pass nvarchar(50) ) --获取自增最大值 declare @flag int select @flag=Isnull(MAX(Id),0) from AkWorkOrderPrintDate --变量 while @flag>0 begin --是否存在这条记录 declare @count int select @count=COUNT(*) from AkWorkOrderPrintDate where Id=@flag if @count=1 begin --拷贝这行的数据 insert into @temp select Id,Title,Value,Remark,‘值错误‘ from AkWorkOrderPrintDate where Id=@flag --测试日期设置 declare @val nvarchar(1000) select @val=Value from @temp where Id=@flag set @val=‘select @a=‘+@val --执行 begin try declare @pass nvarchar(1000) exec sp_executesql @val,N‘@a nvarchar(1000) output‘,@pass output update @temp set Pass=@pass where Id=@flag end try begin catch end catch end set @flag=@flag-1 end select * from @temp
时间: 2024-10-12 21:35:46