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 2005 Forums
 Transact-SQL (2005)
 case with condition

Author  Topic 

tech1
Starting Member

49 Posts

Posted - 2010-06-23 : 13:24:03
this is an odd one.

i have a table where a field contains audits of downloads from a site

QueryType is a parameter the SPROC will be getting but here is
how the field values look typically (from resources/....)

QueryType 1: resources/downloads/static
QueryType 2: resources/downloads/static/loyalty
QueryType 3: resources/downloads/{A NUMBER HERE}


how can I only perform a select where QueryType1 will only get back records that do not contain anything AFTER /loyalty, as this is only for querytype2?

what about getting records where QueryType3 is given and will only get me numbers after the downloads/ and NOT /static or static/loyalty - so its just numbers?

any ideas?

Kristen
Test

22859 Posts

Posted - 2010-06-23 : 18:42:57
1

WHERE MyColumn = 'resources/downloads/static/loyalty'

or perhaps

WHERE MyColumn LIKE '%/loyalty'

2

WHERE MyColumn LIKE 'resources/downloads/%'
AND MyColumn NOT LIKE 'resources/downloads/%[^0-9]%'


I have presumed that "{A NUMBER HERE}" comprises only digits - no ".", no "+" or "-" or any other character.
Go to Top of Page
   

- Advertisement -