Click here to Skip to main content
15,878,814 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hello,
I have Table like
name | skills | area|
________________________
ajay | .net,wcf| hyd
ram | java,.net| bang
I want to find who have candidates skills like java,dot in stored procedure
can u guide or end any snippets in front my application i am using textbox for for giving input like java,.net
Posted
Updated 16-May-12 19:46pm
v3
Comments
Zoltán Zörgő 27-May-12 13:45pm    
Any progress?

 
Share this answer
 
Comments
Maciej Los 17-May-12 13:13pm    
Good link, my 5!
Abhinav S 17-May-12 23:47pm    
Thank you.
Try with this query:
SQL
SELECT name, area FROM  YourTable
WHERE skills LIKE N'%java%' OR skills LIKE N'%.net%' 
ORDER BY name


More on LIKE can be found here.
 
Share this answer
 
v2
Comments
Maciej Los 17-May-12 13:13pm    
Good example, my 5!
First see following function:
SQL
/****** Object:  UserDefinedFunction [dbo].[Split]    Script Date: 2012.05.17. 12:25:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[Split](@String varchar(8000), @Delimiter char(1))
returns @temptable TABLE (items varchar(8000))
as
begin
    declare @idx int
    declare @slice varchar(8000)

    select @idx = 1
        if len(@String)<1 or @String is null  return

    while @idx!= 0
    begin
        set @idx = charindex(@Delimiter,@String)
        if @idx!=0
            set @slice = left(@String,@idx - 1)
        else
            set @slice = @String

        if(len(@slice)>0)
            insert into @temptable(Items) values(@slice)

        set @String = right(@String,len(@String) - @idx)
        if len(@String) = 0 break
    end
return
end

GO

We can use it to find what you want:
SQL
create procedure FindSkilledPeople
    @skillstolook nvarchar(100)
as
begin
SELECT name,skills,area FROM SkilledPeople, (select items from dbo.Split(@skillstolook,',')) as look
where items in (select items from dbo.Split(SkilledPeople.skills,','))
group by name,skills,area
having count(*)=(select count(*) from dbo.Split(@skillstolook,','))
end

In english: list all people who has all skills I am looking for
PS: this is not enough if you need ranking in skills (eg. A,B != B,A)
 
Share this answer
 
v2
Comments
Maciej Los 17-May-12 13:16pm    
Good work, +5!
Zoltán Zörgő 17-May-12 13:39pm    
Thanks!
SQL
SELECT name, area FROM  YourTable
WHERE skills LIKE N'%java%' OR skills LIKE N'%.net%'
ORDER BY name



Good One

%ads before string retrieve all values which have ending string matches with ads

%ads% before string retrieve all values which have string matches with ads anywhere in string

ads% before string retrieve all values which have starts string matches with ads
 
Share this answer
 
First You Have to create a stored procedure like
create procedure procedure1
@skill varchar(50)
as
begin
select * from table1 where skill like %@skill%
end
In code behind  use this stored procedure like

 Dim cmd As SqlCommand = New SqlCommand()

           cmd.Connection = con
           cmd.CommandType = CommandType.StoredProcedure
           cmd.CommandText = "procedure1"
 cmd.Parameters.AddWithValue("@skill", textbox1.text)
cmd.executereader

mark it answer if solves your problem and dont forget to rate..
 
Share this answer
 
v2
This type of question had been asked previously..please follow the link..you will surely get your answer...


www.codeproject.com/Answers/364206/SPLIT-TABLE-COLUMN-VALUE-IN-TO-ANOTHER-COLUMN[^]

make it answer if you got and rate it..

Thanks
Ashish
 
Share this answer
 
above solutions are correct

but it will not work in this scenario.

ex:

name | skills | area|
________________________
ajay | .net,wcf,Java | hyd
ram | java,.net | bang


whene you will searc with following word

.net,java

in this case our answer should be ajay..

but the query will not give perfect ans...
 
Share this answer
 
Comments
Maciej Los 17-May-12 13:15pm    
This is not an naswer! Please, remove this and update your question. Use "Improve question" button.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900