sqlser生成guid与复制造数
作者:互联网
NEWID()可以生成GUID,如果要小写,则LOWER(NEWID())
可生成 2144400c-322c-4673-b24c-6a29db94422c 类似这样的
采用如下方法可复制造数,非常快:
INSERT INTO 表名(字段名)
SELECT 字段名 --可用函数替换要更改的字段
FROM 表名 条件
例子:
INSERT INTO SimMonthBillItem ([ID], [BusinessID], [BillID], [SubjectId], [DueAmount], [UpdateTime], [CreateTime]) select LOWER(NEWID()), [BusinessID], LOWER(NEWID()), [SubjectId], [DueAmount], [UpdateTime], [CreateTime] from SimMonthBillItem where businessid <> 18751388 INSERT INTO SimMonthBill ([ID], [BusinessID], [BillID], [BillType], [BillIndex], [BillMonth], [MonthAmount], [BeginTime], [EndTime], [UpdateTime], [CreateTime]) select LOWER(NEWID()), [BusinessID], LOWER(NEWID()), [BillType], [BillIndex], [BillMonth], [MonthAmount], [BeginTime], [EndTime], [UpdateTime], [CreateTime] from SimMonthBill where businessid <> 18751388 INSERT INTO Received ([BillID], [BillItemID], [Amount], [ReceivedType], [PayID], [ReceivedTime], [CreateTime], [OperatorID], [Explain], [DeductionID], [ToAccountID], [ToAcountTime], [OAApplyCode], [IsAfterClear]) select [BillID], [BillItemID], [Amount], [ReceivedType], [PayID], [ReceivedTime], [CreateTime], [OperatorID], [Explain], [DeductionID], [ToAccountID], [ToAcountTime], [OAApplyCode], [IsAfterClear] from Received where billid not in (83636374,83636376)
标签:INSERT,LOWER,BusinessID,sqlser,UpdateTime,生成,NEWID,guid,CreateTime 来源: https://www.cnblogs.com/carlvine/p/12893089.html