if object_id('tb')is not null drop table tb go create table tb (年度 int,号码 nvarchar(25),姓名 nchar(50)) insert into tb values(2008,'00001','张三') insert into tb values(2008,'00001','张三') insert into tb values(2008,'00002','张三') insert into tb values(2008,'00003','李四') insert into tb values(2009,'00003','李四') select 年度,号码,姓名,count(1) 号码个数 from tb group by 年度,姓名,号码结果 2008 00001 ?? 2 2008 00002 ?? 1 2008 00003 ?? 1 2009 00003 ?? 1
把字段改为nvarchar(长度) 然后插入数据用 insert into tb(name) values(N'张三')
drop table tb
go
create table tb (年度 int,号码 nvarchar(25),姓名 nchar(50))
insert into tb values(2008,'00001','张三')
insert into tb values(2008,'00001','张三')
insert into tb values(2008,'00002','张三')
insert into tb values(2008,'00003','李四')
insert into tb values(2009,'00003','李四')
select 年度,号码,姓名,count(1) 号码个数
from tb
group by 年度,姓名,号码结果
2008 00001 ?? 2
2008 00002 ?? 1
2008 00003 ?? 1
2009 00003 ?? 1
把字段改为nvarchar(长度)
然后插入数据用
insert into tb(name) values(N'张三')