表如下 customs int nvchar contom_id name 1 syl 2 yl 15 ss
为什么这样子进去 @id赋 1 不会索引到 15呢?
请求解决谢谢了!~
%1% SQL code: SELECT * from customs WHERE (contom_id LIKE ltrim(@id)+'%')
會
SQL code: if object_id('[tb]') is not null drop table [tb] go create table [tb] (contom_id int primary key,name nvarchar(6)) insert into [tb] select 1,'syl' union all select 2,'yl' union all select 15,'ss' go set showplan_text on go declare @id int set @id=2
select * from [tb] where contom_id LIKE @id go set showplan_text off /* StmtText |--Clustered Index Scan(OBJECT: */
要用模糊查询的 还是不行哦!~!~ 2楼不行? SQL code
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighli