Yo tratar de responder lo que tu preguntar, tratar de usar esto:
Código SQL:
Ver originalCREATE FUNCTION [dbo].[SplitApplication](@applicationid VARCHAR(2000))
RETURNS @RtnValue TABLE
(
Id INT IDENTITY(1,1),
DATA nvarchar(100)
)
AS
BEGIN
DECLARE @Cnt INT, @SplitOn nvarchar(5)
SET @SplitOn = ','
SET @Cnt = 1
While (Charindex(@SplitOn,@applicationid)>0)
BEGIN
INSERT INTO @RtnValue (DATA)
SELECT
DATA = ltrim(rtrim(SUBSTRING(@applicationid,1,Charindex(@SplitOn,@applicationid)-1)))
SET @applicationid = SUBSTRING(@applicationid,Charindex(@SplitOn,@applicationid)+1,len(@applicationid))
SET @Cnt = @Cnt + 1
END
INSERT INTO @RtnValue (DATA)
SELECT DATA = ltrim(rtrim(@applicationid))
RETURN
END
GO
how TO USE :
SELECT * FROM TABLE WHERE DATA IN (
SELECT DATA FROM SplitApplication('1,1,1,1')
)
como la usarias en tu ejemplo:
SELECT * FROM tabla D WHERE ubicacion IN (SELECT DATA FROM SplitApplication('ubicacion1,ubicacion2,ubicacion3'))
preguntar si tu no entender.....yo responder