case

Sql Server 2005 Fulltext case sensitivity problem

I seem to have a weird bug in Microsoft SQL Server 2005 where FREETEXT() searches are somewhat case-sensitive despite the collation being case-insensitive (Latin1_General_CI_AS). First of, LIKE queries are perfectly case-insensitive, so WHERE column LIKE '%word%' and WHERE column LIKE '%Word%' return the same results. Also, FREE...

Ruby Convert If Statements to Case

Is it possible to use a case statement to replace these if statements? if (a%3 == 0) then puts "%3" elsif (a%4 == 0) then puts "%4" elsif (a%7 == 0 && a%13 == 0) then puts "%%" ...

TSQL - Use a Derived Select Column in the Where Clause

Is there a way in TSQL to do something like this: select a,b,c, case when a=1 then 5 when a=2 then 6 end as d from some_table where d=6 The actual case statement is really complex, so I'm trying to avoid repeating it in the where clause? Are there any tricks to do this? (I think there's a trick in MySQL to use "having d=6"). ...

check string for all lowercase letters in powershell

I want to be able to test if a powershell string is all lowercase letters. I am not the worlds best regex monkey, but I have been trying along these lines: if( $mystring -match "[a-z]^[A-Z]" ) { echo "its lower!" } But of course they doesn't work, and searching the interwebs hasn't got me anywhere. Does anyone know the way to do this...

Code before the first 'case' in a switch-statement

In C it's possible to write code before the first case label. Are there any cases for which it is useful to do this or is it just a 'dead block of code' ? E.g.: switch (...) { { int a = 0x2a; printf("%d\n", a); } case 0: ... } ...

Is it possible for WHEN to check the if the variable belongs to an array?

How can I do something like this ? or do i need to use IF all the time? ar = [["a","b"],["c"],["d","e"]] x = "b" case x when ar[0].include?(x) puts "do something" when ar[1].include?(x) puts "do else" when ar[2].include?(x) puts "do a 3rd thing" end I'm using ruby 1.8.7 ...

Python: getting filename case as stored in Windows?

Though Windows is case insensitive, it does preserve case in filenames. In Python, is there any way to get a filename with case as it is stored on the file system? E.g., in a Python program I have filename = "texas.txt", but want to know that it's actually stored "TEXAS.txt" on the file system, even if this is inconsequential for vario...

Retain case when using str_ireplace?

I am building a search that will wrap the searched text with a <span> tag and i have this code working ok: str_ireplace($q,'<span>'.$q.'</span>',$row[name]); The problem is, if a user searches for Tom is will show Tom which is cool, but if they put in tom because of the str_ireplace it would show tom, does that make sense? The real is...

Is there any way to access the expression from within a ruby case statement?

Hi All, I would like to access the case statements expression from within a then clause i.e. food = "cheese" case food when "dip" then "carrot sticks" when "cheese" then "#{expr} crackers" else "mayo" end where in this case expr would be the current value of food. In this case I know, I could simply access the variable food, howeve...

SQL [CASE Query View]

SELECT DT, FlowParam, Abs_P, T, Volume, Energy, FlowTime_T, (SELECT ' > 1 ' AS Expr1 WHERE ( (SELECT COUNT(*) AS Expr2 FROM dbo.BACS_Alarm_1 WHERE (DT_T >= dbo.BACS_HourFlow_1.DT_T) AND (DT_T <= dbo.BACS_HourFlow_1.DT_T + dbo.BACS_HourFlow_1.FlowTime_T) ) > 1 )) AS...

Ignoring case on E4X node names and attributes?

Does anyone know of a trick to ignore upper/lower/camelcase on XML node names and attributes? A quick example: I give an XML file to my client which contains an XML attribute named fooID but the client could change the XML, and - not being aware of upper/lowercaseness change or add an attribute under 'fooid'. Naturally my parser (in AS3...

My SQL Subquery - Blob returned, need text value

Hi, I'm trying to write a case statement in mysql which checks if a person has booked a room. If they have, then return the roomtype, otherwise return an informative message. ( CASE WHEN (eab.accommodation_id > 0) THEN (SELECT roomtype FROM event_accomodation WHERE id = eab.accommodation_id) ELSE (IFNULL(eab.accommodation_id, 'No accom...

Case sensitive replace for case insensitive search with regex

Ok so I doing the following regex replace: Input: ([Ll])ocation Output: \1abel That replaces Location with Label and location with label. However, if I want to replace location with geocode and Location with Geocode, can I do that with a single regex? I'm doing a search and replace in notepad++ at the moment, but I've had this probl...

Case statement with multiple whens...not working!

This is a simplified version of what I'm doing, but I can't get anything to work. The statement gives me an error without the comma after 'ERR'. I want the column to be 'Month' and I tohught this would work but I'm having a ton of trouble. Thanks for your help! select a.POL_PRI_RSK_ST_CD, a.MASTER_COMPANY_NBR, case when a.char04...

Counting Rows between dates...

I'm using a CTE to generate a range of dates. 12/02/2010 10:00:00 12/02/2010 10:59:59 12/02/2010 11:00:00 12/02/2010 11:59:59 12/02/2010 12:00:00 12/02/2010 12:59:59 I then left join this to a indexed view containing huge amounts of date. I have 2 options for counting between the date ranges 1) i would SUM(case) test the log_date t...

Switch character case, php

How can i swap around the case of the characters in a string, for example: $str = "Hello, My Name is Tom"; After i run the code i get a result like this: $newstr = "hELLO, mY nAME Is tOM"; Is this even possible? ...

.htaccess or other URL Case Sensitive

My server is Case Sensitive, and id like to turn it to inSensitive. Example of what I mean is lets say I upload Fruit.php Well then going to this file wont work: www.website.com/fruit.php but this one will: www.website.com/Fruit.php Is there a way so Fruit.php and fruit.php will work? also with the directories. i.e: /Script/script.php ...

How do you use a switch case statement to convert Letters into numbers

I am making a black jack game and I need to use a switch case statement to convert A to 11, and T, Q, J, and K to 10, however I am not sure how to do the code. Would someone mind helping me with this problem? So far I have: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplicati...

bash case statements evaluate to strings

I've caught the functional programming bug, so naturally nothing is good enough for me anymore. ;) So, in bash one could write: case $status in "foo") status="bar" ;; "baz") status="buh" ;; *) status=$status ;; esac but I'm afraid of typos, so I'd prefer to write: status=case $status in "foo") "bar" ;; "baz") "buh" ;; *...

Dependency propery for ValueConverter or rebind control?

Hi all, I have custom control with some text in content template: <ControlTemplate TargetType="{x:Type local:TouchScreenKey}"> <TextBlock><ContentPresenter Content="{TemplateBinding Title, Converter={StaticResource CaseConverter}}" /></TextBlock> </ControlTemplate> and custom IValueConverter CaseConverter - with property Upper...