SQL server Charindex方法在自定义方法里的使用,拿不到值
方法定义如下:IFOBJECT_ID(N'dbo.elicit')ISNOTNULLDROPFUNCTIONdbo.elicit;GOCREATEFUNCTIONdbo....
方法定义如下:
IF OBJECT_ID (N'dbo.elicit') IS NOT NULL
DROP FUNCTION dbo.elicit;
GO
CREATE FUNCTION dbo.elicit(
@parameters varchar(400) = '',
@key varchar(20) = ''
) RETURNS varchar(30)WITH EXECUTE AS CALLER
AS
BEGIN
declare @strReturn varchar(30)
declare @vPos int
set @vPos = charindex(@key,@parameters);
set @strReturn = convert(varchar(5),@vPos)
return @strReturn
END
GO
select dbo.elicit('key1','key:value,key1:value1')
返回字符串的值总是0, 为什么?怎么改? 展开
IF OBJECT_ID (N'dbo.elicit') IS NOT NULL
DROP FUNCTION dbo.elicit;
GO
CREATE FUNCTION dbo.elicit(
@parameters varchar(400) = '',
@key varchar(20) = ''
) RETURNS varchar(30)WITH EXECUTE AS CALLER
AS
BEGIN
declare @strReturn varchar(30)
declare @vPos int
set @vPos = charindex(@key,@parameters);
set @strReturn = convert(varchar(5),@vPos)
return @strReturn
END
GO
select dbo.elicit('key1','key:value,key1:value1')
返回字符串的值总是0, 为什么?怎么改? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询