使用inputparame时,使用的是 varchar(20),和数据库中的DEPARTNAME完全匹配,可以查出值:
1 USE [test] 2 GO 3 4 SET ANSI_NULLS OFF 5 GO 6 7 SET QUOTED_IDENTIFIER OFF 8 GO 9 10 11 ALTER PROCEDURE [dbo].[pro_testprocedure](@inputparame varchar(20)) 12 13 AS 14 15 BEGIN 16 SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo 17 from his_depart 18 END 19 GO
而使用inputparame时,使用的是 varchar时,却没用能够用过varindex得到值:
1 USE [test] 2 GO 3 4 SET ANSI_NULLS OFF 5 GO 6 7 SET QUOTED_IDENTIFIER OFF 8 GO 9 10 11 ALTER PROCEDURE [dbo].[pro_testprocedure](@inputparame varchar) 12 13 AS 14 15 BEGIN 16 SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo 17 from his_depart 18 END 19 GO
新手向 =。。=