SQL Server 通过游标重新定义单据数据的单据编号
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