use master -- 第一步,查找出所有无套系类别的订单号,并保存; select identity(int,1,1) as autoid,id into [db].[dbo].[dindan_temp] from [db].[dbo].[dindan] where [txtype] = NULL or [txtype] = '' go -- 第二步,更新空的套系类别订单; declare @count int declare @index int declare @order nvarchar(50) declare @txtype nvarchar(50) select @count = count(id) from [db].[dbo].[dindan_temp] print @count set @index = 1 print @index while @index <= @count begin select @order = id from [db].[dbo].[dindan_temp] where autoid = @index select @txtype = [txtype] from [20150].[dbo].[dindan] where id = @order update [db].[dbo].[dindan] set [txtype] = @txtype where id = @order set @index = @index + 1 end go -- 第三步,删除表; drop table [db].[dbo].[dindan_temp] go --查询有无套系类型空的订单; -- select [txtype],* from [db].[dbo].[dindan] where [txtype] = NULL or [txtype] = ''