April 4, 2014 at 3:28 pm
Hello,
I am having a hard time getting a variable recognized in a function. The variable is not being seen properly in the charindex function.
@ExtType contains = X
@PhoneNo contains = +1 (202) 123-9876 X012
select @intPos = charindex(@ExtType,Upper(@PhoneNo))
I think it is because it is missing the ' ' tick marks.
Anyone ever have this problem?
Thank you in advance for your time.
lmnorms
April 4, 2014 at 4:03 pm
Can you post your variables declaration?
You might have a truncation problem. Check the following code that looks the same but has an important difference.
DECLARE @ExtType varchar(10) = 'X',
@PhoneNo varchar(20) = '+1 (202) 123-9876 X012',
@intPos int
select @intPos = charindex(@ExtType,Upper(@PhoneNo))
SELECT @intPos
GO
DECLARE @ExtType varchar(10) = 'X',
--Note the change on the variable length
@PhoneNo varchar(10) = '+1 (202) 123-9876 X012',
@intPos int
select @intPos = charindex(@ExtType,Upper(@PhoneNo))
SELECT @intPos
GO
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply