Stand-generated data, and process data

xiaoxiao2021-03-06  76

if exists (select name from sysobjects where name = 'emp_khbh1' and type = 'u') drop table emp_khbh1gocreate table emp_khbh1 (ickh int, empbh int, xm char (12)) go-- recording process is repeated if exists (select name from sysobjects where name = 'chanage' and type = 'tr') drop trigger chanagegocreate trigger chanageon emp_khbh1instead of insertasbegininsert into emp_khbh1 (ickh, empbh, xm) select ickh = (case when exists (select 1 from emp_khbh1 a where a.ickh = ickh) then ickh-1 else ickh end), empbh = empbh, xm = xmfrom insertedendgo-- a randomly generated data table if exists (select name from sysobjects where name = 'sj_rand' and type = 'P') drop proc sj_randgocreate Proc SJ_Rand @m Intasbegindeclare @n tent @ n = 1WHILE @n <

= @m

Begin INSERT INTO EMP_KHBH1 (ICKH, EMPBH, XM) Select ICKH = CAST (1000000 Rand () * 10000000 AS INT), EMPBH = 10000 @ n, xm = nchar (19999 (Case When Rand () * 10000 <= 2000 THEN RAND () * 10000 else rand () * 1000 end) (Case When (19968 rand () * 30000) <19968 20902 THEN NCHAR (19968 rand () * 10000) Else '' end) Nchar (19968 () * 10000 <= 20902 Then Rand () * 10000 else rand () * 1000 end)) set @ n = @ n 1ENDENDENDGO - call proCexec sj_rand 100gosect * from Emp_Khbh1 Go

转载请注明原文地址:https://www.9cbs.com/read-120682.html

New Post(0)