if exists(select name from sysobjects
where name = 'emp_khbh1' and type = 'u')
drop table emp_khbh1
gocreate table emp_khbh1(ickh int,empbh int,xm char(12))
go--處理重複的記錄
if exists (select name from sysobjects
where name = 'chanage' and type = 'tr')
drop trigger chanage
gocreate trigger chanage
on emp_khbh1
instead of insert
asbegin
insert 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=xm
from inserted
endgo
--隨機生成乙個表的資料
if exists (select name from sysobjects
where name = 'sj_rand' and type = 'p')
drop proc sj_rand
gocreate proc sj_rand @m int
asbegin
declare @n int
set @n=1
while @n<
=@mbegin
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+(case when rand()*10000<=20902 then rand()*10000 else rand()*1000 end))
set @n=@n+1
endend
go--呼叫proc
exec sj_rand 100
goselect * from emp_khbh1
go
Excel隨機生成資料
concatenate函式是乙個文字連線函式,非常簡單,和 的效果一樣。concatenate是乙個文字連線函式 語法 concatenate text1,text2,text3.其中text表示乙個個要連線起來的文字。隨機小寫字母 char int rand 25 97 隨機大寫字母 char i...
Excel隨機生成資料
concatenate函式是乙個文字連線函式,非常簡單,和 的效果一樣。concatenate是乙個文字連線函式 語法 concatenate text1,text2,text3.其中text表示乙個個要連線起來的文字。隨機小寫字母 char int rand 25 97 隨機大寫字母 char i...
Python3 隨機漫步生成資料並繪製
python隨機漫步生成資料並繪製 random walk.py from random import choice 生成隨機漫步的資料類 class randomwalk def init self,num points 5000 初始化隨機漫步的屬性 self.numpoints num poi...