if OBJECT_ID ('test') is not null
drop table test
go
create table test(id varchar(12),username varchar(10),regtime datetime,tel varchar(10))
create clustered index index_id on test(id)
declare @i int=1
while @i<1000
begin
insert into test
select 'ABCDEF'+right((1000+@i),3),'李_'+RIGHT((1000+@i),3),GETDATE(),'8976'+RIGHT((1000+@i),4)
set @i=@i+1
end
测试语句
SET STATISTICS IO ON
1)select * from test where ID like 'ABCDEF9%'
2)SELECT * FROM test
3)SELECT * FROM test where LEFT(id,7)='ABCDEF9'
结果