SQL2008 存储过程参数相关

时间:2022-01-05 15:59:10

使用inputparame时,使用的是 varchar(20),和数据库中的DEPARTNAME完全匹配,可以查出值:

 USE [test]
GO SET ANSI_NULLS OFF
GO SET QUOTED_IDENTIFIER OFF
GO ALTER PROCEDURE [dbo].[pro_testprocedure](@inputparame varchar(20)) AS BEGIN
SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo
from his_depart
END
GO

Code1

而使用inputparame时,使用的是 varchar时,却没用能够用过varindex得到值:

 USE [test]
GO SET ANSI_NULLS OFF
GO SET QUOTED_IDENTIFIER OFF
GO ALTER PROCEDURE [dbo].[pro_testprocedure](@inputparame varchar) AS BEGIN
SELECT DEPARTNAME, charindex( @inputparame, DEPARTNAME) as indexNo
from his_depart
END
GO

Code2

新手向 =。。=