Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 and operator string split using comma seperator

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-08 : 23:04:36
I have the following values came with in a parameter: prmAnd

"Application, for payment, order history"

Is it possible to split using comma and use and operator.

after split want to do this:

field1 = 'Application' and field1 = 'For payment' and field1='order history'


Thank you very much for the helpful info.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-09 : 01:12:01
see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25830&SearchTerms=CSVTable
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-02-09 : 04:46:56
http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/

- Lumbago
My blog-> www.thefirstsql.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-09 : 08:19:29
<<
field1 = 'Application' and field1 = 'For payment' and field1='order history'
>>

Does the field name differ? You used field1 only

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2011-02-09 : 08:52:25
He is trying to make the parameter work like an IN(@Param) operator I think...

so that this "Application, for payment, order history"

will become this Field1 IN('Application', 'for payment', 'order history')

Maybe the OP could clarify ...seems to be a popular topic choice these days



Poor planning on your part does not constitute an emergency on my part.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-09 : 10:57:08
quote:
Originally posted by madhivanan

<<
field1 = 'Application' and field1 = 'For payment' and field1='order history'
>>

Does the field name differ? You used field1 only

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2011-02-09 : 10:58:34
Hello Madhivanan,

Yes, i have 16 fields, to be checked.

field1 to field 16 using all those parameter values against and , or ,not operators.

Thank you.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-10 : 03:17:52
quote:
Originally posted by cplusplus

Hello Madhivanan,

Yes, i have 16 fields, to be checked.

field1 to field 16 using all those parameter values against and , or ,not operators.

Thank you.


You need to give more informations to help you
Post some more sample data

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -