标签:rom cursor server etc locate where pen tail ext
DECLARE @Index INT
SET @Index=100
DECLARE UpdateCursor
CURSOR FOR (SELECT DISTINCT AA.Id FROM dbo.表 AA WHERE 数据过滤条件 )
OPEN UpdateCursor
DECLARE @DetailId NVARCHAR(36)
DECLARE @Name NVARCHAR(36)
FETCH NEXT FROM UpdateCursor INTO @DetailId
WHILE @@FETCH_STATUS=0
BEGIN
SET @Name=‘OQ14091‘+ CONVERT(NVARCHAR,@Index)----重新设置标号
UPDATE dbo.表 SET Name=@Name WHERE Id= @DetailId
SET @Index=@Index+1
FETCH NEXT FROM UpdateCursor INTO @DetailId
END
CLOSE UpdateCursor
DEALLOCATE UpdateCursor
GO
标签:rom cursor server etc locate where pen tail ext
原文地址:https://www.cnblogs.com/hualiuliu/p/11453547.html