Can somebody advise idea, how you can match user input (couple of words) to appropriate tags in system (all of them also 1 or N words)?

Here's sample to show problem: I've got a Tags, designated to things. For instance (tags are separated by COMA, however in real existence I've regards to table)

Object                  Tags
Earth                   World, reality
World of warcraft 3     World Of warcraft, virtual reality
quake                   game, virtual

I must get following:

User Enter 'World': outcome is 'Earth'

User Enter 'Wow': outcome is 'wow 3'

Which was simple, exact search. But:

User Enter 'game world': results ought to be search by two tags - 'earth', 'quake'

User enter 'virtual reality': returns all 3 records

User enter 'reality virtual': Earth, quake

I'm using t-sql for search, full-text-search is enabled and accustomed to also look for a key phrases in primary text. C# is middle tier. However I would rather have solution on t-sql level.

UPDATE 1 First what I will do, would be to disallow spaces in tags, like on stackoverflow. Every other ideas are upreciated.

You might like to investigate while using Velocity caching engine, because it has quite wealthy support for marking (GetObjectsByTag, GetObjectsByAllTags, GetObjectsByAnyTag) and all sorts of the effort continues to be accomplished for you! All you want do is load your objects in to the cache with appropriate tags.

You need a split function to separate the tags within the search string, and continue to match these within the tags

FUNCTION [dbo].[SplitString]
(
    	@String VARCHAR(8000) ,
    	@Delimiter	VARCHAR(10)
)
RETURNS @RetTable TABLE(
    	String varchar(1000)
)
AS 
BEGIN
    DECLARE @i INT ,
    		@j INT
    SELECT 	@i = 1
    WHILE @i <= LEN(@String)
    BEGIN
    	SELECT	@j = CHARINDEX(@Delimiter, @String, @i + 1)
    	IF @j = 0
    	BEGIN
    		SELECT	@j = LEN(@String) + 1
    	END
    	INSERT	@RetTable SELECT LTRIM(RTRIM(SUBSTRING(@String, @i, @j - @i)))
    	SELECT	@i = @j + LEN(@Delimiter)
    END
    RETURN
END


DECLARE @String VARCHAR(8000) ,
    	@Delimiter	VARCHAR(10)
DECLARE @RetTable TABLE(
    	String varchar(1000)
)

SELECT  @String = 'world of ',
    	@Delimiter = ' '

--split FUNCTION that returns a table of tags to match
    DECLARE @i INT ,
    		@j INT
    SELECT 	@i = 1
    WHILE @i <= LEN(@String)
    BEGIN
    	PRINT @i
    	SELECT	@j = CHARINDEX(@Delimiter, @String, @i + 1)
    	IF @j = 0
    	BEGIN
    		SELECT	@j = LEN(@String) + 1
    	END
    	INSERT	@RetTable SELECT LTRIM(RTRIM(SUBSTRING(@String, @i, @j - @i)))

    	SELECT	@i = @j + LEN(@Delimiter)
    END

SELECT * FROM @RetTable
--split FUNCTION that returns a table of tags to match

DECLARE @Table TABLE(
    	Objects VARCHAR(MAX),
    	Tags VARCHAR(MAX)
)

INSERT INTO @Table (Objects,Tags) SELECT 'Earth', 'World,reality'
INSERT INTO @Table (Objects,Tags) SELECT 'World of warcraft 3', 'World Of warcraft,virtual,reality'
INSERT INTO @Table (Objects,Tags) SELECT 'quake', 'game,virtual'


SELECT  DISTINCT 
    	t.* 
FROM    @Table t,
    	@RetTable r
WHERE   Tags LIKE '%' + String + '%,%'
OR  	Tags LIKE '%,%' + String + '%,%'
OR  	Tags LIKE '%,%' + String + '%'

something of that nature.

It's Not recommended to place such complex business logic to your SQL code! Place it in the centre tier and when you are concerned about performance apply certain caching mechanism.