SQL2008 存储过程参数相关

9/1/2015来源:SQL技巧人气:5399

SQL2008 存储过程参数相关

使用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 AS14 15 BEGIN16     SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo17     from his_depart18 END19 GO
Code1

而使用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 AS14 15 BEGIN16     SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo17     from his_depart18 END19 GO
Code2

新手向 =。。=