SELECT
tblPropertyLocationSubCategory.PLSId
, tblPropertyLocationSubCategory.PLSName
, tblPropertyLocationSubCategory.PLCId
, tblPropertyLocationCategory.PLCName
FROM
tblPropertyLocationSubCategory
INNER JOIN tblPropertyLocationCategory
ON tblPropertyLocationSubCategory.PLCId = tblPropertyLocationCategory.PLCId
WHERE
PLSId in(select Item from [dbo].[SplitString](@sPLSName,','))
Asked
Active
Viewed 5,436 times
-7
-
1dbo.SplitString needs to be manually created as its not a built in function, have you done so? There is an implementation here: http://stackoverflow.com/questions/10914576/t-sql-split-string – Alex K. Oct 08 '15 at 12:38
-
2Please ask a question rather than just paste the query. The error is showing that you do not have a table/function named SplitString – Michael B Oct 08 '15 at 12:38
1 Answers
3
First create function,
CREATE FUNCTION SplitString
(
@Input NVARCHAR(MAX),
@Character CHAR(1)
)
RETURNS @Output TABLE (
Item NVARCHAR(1000)
)
AS
BEGIN
DECLARE @StartIndex INT, @EndIndex INT
SET @StartIndex = 1
IF SUBSTRING(@Input, LEN(@Input) - 1, LEN(@Input)) <> @Character
BEGIN
SET @Input = @Input + @Character
END
WHILE CHARINDEX(@Character, @Input) > 0
BEGIN
SET @EndIndex = CHARINDEX(@Character, @Input)
INSERT INTO @Output(Item)
SELECT SUBSTRING(@Input, @StartIndex, @EndIndex - 1)
SET @Input = SUBSTRING(@Input, @EndIndex + 1, LEN(@Input))
END
RETURN
END
Then execute your query, it will work.

Pedram
- 6,256
- 10
- 65
- 87