34,590
社区成员
发帖
与我相关
我的任务
分享
select number,
char(64+case number%6 when 0 then 6 else number%6 end)
from master..spt_values
where type='p' and number between 1 and 24
/*
number
----------- ----
1 A
2 B
3 C
4 D
5 E
6 F
7 A
8 B
9 C
10 D
11 E
12 F
13 A
14 B
15 C
16 D
17 E
18 F
19 A
20 B
21 C
22 D
23 E
24 F
*/
create table sp(id int,name varchar(10),盘点码 varchar(1))
insert into sp(id,name)
select 1,'aa' union all
select 2,'bb' union all
select 3,'cc' union all
select 4,'dd' union all
select 5,'ee' union all
select 6,'ff' union all
select 7,'gg' union all
select 8,'hh'
go
update sp set 盘点码=char(ascii(newid())%4+65)
go
select * from sp
/*
id name 盘点码
----------- ---------- ----
1 aa B
2 bb A
3 cc B
4 dd D
5 ee C
6 ff D
7 gg B
8 hh C
(8 行受影响)
*/
go
drop table sp