February 27, 2003 at 4:44 am
Why can I pass as parameter a table field to a multi-statement table-valued function?
For example I have the following table(Companies):
CompanyID Indices
_________ ____________
ABR BET-C
GTR BET, BET-C
ILR BET-C, BET-FI
TER BET, BET-FI
ZWQ BET-C
Also I have a multi-statement table-valued function who take as parameters a string and a separator and it return a table containing the splited string:
ALTER FUNCTION fn_Split (@str varchar(1000), @sep varchar(5))
RETURNS @components TABLE (piece varchar(20))
AS
BEGIN
DECLARE @pos int
select @pos=charindex(@sep, @STR)
WHILE @pos > 0
BEGIN
insert @components select ltrim(rtrim(substring(@str,1,@pos-1)))
select @STR=ltrim(rtrim(right(@str,len(@str)-@pos-len(@sep)+1)))
select @pos=charindex(@sep, @STR)
END
insert @components select ltrim(rtrim(@str))
RETURN
END
When I execute the following request:
select * from companies
where 'bet' in (select * from dbo.fn_split(Indices ,','))
I receive the following error:
Server: Msg 155, Level 15, State 1, Line 2
'Indices' is not a recognized OPTIMIZER LOCK HINTS option.
February 27, 2003 at 5:01 am
try putting quotes around 'indices'
February 27, 2003 at 6:01 am
quote:
try putting quotes around 'indices'
It would consider the String 'Indices' not the table's field Indices
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply