SQL Stored Procedure LIKE

后端 未结 7 1893
野的像风
野的像风 2021-02-20 11:38

This is a simple question and I can\'t seem to think of a solution.

I have this defined in my stored procedure:

@communityDesc varchar(255) = NULL
         


        
7条回答
  •  再見小時候
    2021-02-20 12:31

    You can do this by splitting your string using a split function provided here. The function returns a table having a single column which holds your tokens (i.e. 'aaa', 'bbb' ...).

    Your query should look like this:

    -- get the splits
    SELECT Name INTO #someTemp
    FROM dbo.splitstring(@communityDesc)
    
    -- get data where area in within description
    SELECT 1
    FROM yourTable T
    WHERE EXISTS (SELECT 1 FROM #someTemp tmp WHERE T.Area = tmp.Name)  
    

提交回复
热议问题