使用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獲得值:ide
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
新手向 =。。=spa