July 18, 2011 at 11:42 am
I am having the Table
create table test
(
id int,
name1 varchar(50),
name2 varchar(50)
)
The Results in this Table are:-
id name1name2
1 1,2,3
2 2,3,4
3 4,5 5.6
Now I am Compring with the another string:-
declare @string varchar(max)
select * from test where @string in (name1)
anybody plz give the soution for this....
Thanks in advance
July 18, 2011 at 12:12 pm
although the column naming conventions seem to suck :sick: ...
there are a number of split functions to be found at SSC.
e.g. http://www.sqlservercentral.com/articles/Tally+Table/72993/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 18, 2011 at 2:45 pm
Or you could just reverse your logic in this case.
select * from test where name1 like '%' + @string '%'
This may or may not be slower than splitting depending on indexes, size of the table, etc etc etc...
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 18, 2011 at 9:36 pm
I wa
I want to check the condition like
name = 'as,de,fr,re'
@name = 'as,re'
select * from sometable where name in (@name)
can anybody help me in this regards
July 18, 2011 at 9:38 pm
Jeff Moden's article here[/url]. It was suggested above, a suggest it again. Read this, it is exactly what you are trying to do.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 20, 2011 at 12:48 pm
spadavala82 (7/18/2011)
...The Results in this Table are:-
id name1name2
1 1,2,3
2 2,3,4
3 4,5 5.6
Now I am Compring with the another string:-
...
[/URL]
If you're in the process of designing this table, then I'd suggest containing these values in separate rows. This is one example where denormalization definately won't buy you any performance optimization or ease of use.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply