2 Replies - 260 Views - Last Post: 29 August 2013 - 11:55 AM

#1 danrche  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 02-February 12

Case Statement Help Please ... :D

Posted 29 August 2013 - 09:25 AM

Table =
abcplab.groupname
lab.groupname
workstation.groupname

I'm trying to list out everything with Lab in it using the following:


Select CASE CHARINDEX('lab', column, 1)
   WHEN > 0 THEN 'lab'
   Else 'OfficePC'
  End As 'Type'
from dbo.table




I'm getting an Incorrect Syntax near '>' message. Surely I'm missing something here, can anyone point me in the right direction?

Is This A Good Question/Topic? 0
  • +

Replies To: Case Statement Help Please ... :D

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8955
  • View blog
  • Posts: 33,571
  • Joined: 12-June 08

Re: Case Statement Help Please ... :D

Posted 29 August 2013 - 09:36 AM

2	   WHEN > 0 THEN 'lab'


this is not a full expression.


2	   WHEN [need something here to have the greater than sign evaluate against] > 0 THEN 'lab'



example:


Select CASE 
   WHEN CHARINDEX('lab', column, 1) > 0 THEN 'lab'
   Else 'OfficePC'
  End As 'Type'
from dbo.table


Was This Post Helpful? 2
  • +
  • -

#3 danrche  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 9
  • Joined: 02-February 12

Re: Case Statement Help Please ... :D

Posted 29 August 2013 - 11:55 AM

huh, that was it, thanks mod
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1