Please update your Flash Player to view content.

Online Users

0 users and 305 guests online

Monthly Winners

  • images/stories/gifts/HariHara.jpg
  • images/stories/gifts/Hemalatha.jpg
  • images/stories/gifts/Mahesh.jpg
  • images/stories/gifts/MaheshGuptha.jpg
  • images/stories/gifts/Naresh.jpg
  • images/stories/gifts/Nithin.jpg
  • images/stories/gifts/Sudhir.jpg
  • images/stories/gifts/Usha.jpg
  • images/stories/gifts/gajavelly.jpg

Top Earners

Daily Toppers

Last Points Earned

Tech Shatabdhi Radio


Latest Updates

Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Added 100% compatibility to all mobile phones


Weekly toppers, star of the day modules added.


Certificates and points sent to August Winners.


Interview Experiences module Added


Win A Weekly Video Library Contest Started


Upcoming Events

No events found.
Sign in with Facebook

Video Comments

Redeem Points


Most Referral Users

Gowridevi
21
Nithin Mohan
12
BangaruBabu Pureti
8
DurgaPrasad
5
somanatha reddy.g
4
100% Non Commercial
Lets Help Lets Grow

Circles

All Friends
Welcome, Guest
Please Login or Register.    Lost Password?

Conditional WHERE clauses in T-SQL
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Conditional WHERE clauses in T-SQL
#2061
Conditional WHERE clauses in T-SQL 1 Year, 11 Months ago Karma: 2
Conditional WHERE clauses in T-SQL using comparison operators (Important)

-- Declare some local variables. Actually, we are creating a pair of variables
-- for each column included in our WHERE clause.
-- The first variable represents the value we are filtering and the second
-- represents the "operator" for the filter.

declare @companyName varchar(255)
declare @companyNameOp varchar(2)
declare @country varchar(255)
declare @countryOp varchar(2)

-- Let's set some sample values now. The values you see here represent the second
-- of the two scenarios described above, i.e. all records for companies located in Germany,
-- excluding companies starting with the letter A

-- Operators are defined here with arbitrary, two-letter values.
-- Of course you could define your own set of operators, with different
-- naming conventions. For our example, here's the meaning of each possible
-- value:

-- ne = not equal
-- eq = equal
-- bg = begins with
-- ed = ends with
-- ct = contains

-- For our example, we are using only varchar fields in our WHERE clause.
-- It is very easy, though, to define operators for other data types as well.


set @companyname = 'A%'
set @companynameOp = 'ne'
set @country = 'Germany'
set @countryOp = 'eq'



-- Ok, now let's form our query.

select
customerid, companyname, country
from
customers
where
case @companyNameOp
when '' then 1 -- Operator not defined, get everything
when 'eq' then -- Operator is "equals"
case when companyname like @companyName then 1 else 0 end
when 'bg' then -- Operator is "begins with"
case when companyname like @companyName +'%' then 1 else 0 end
when 'ed' then -- Operator is "ends with"
case when companyname like '%' + @companyName then 1 else 0 end
when 'ct' then -- Operator is "contains"
case when companyname like '%' + @companyName +'%' then
1 else 0 end
when 'ne' then -- Operator is "not equal"
case when companyname not like @companyName then 1 else 0 end end =1

AND

-- Same approach for the second field

case @countryOp
when '' then 1
when 'eq' then
case when country like @country then 1 else 0 end
when 'bg' then
case when country like @country +'%' then 1 else 0 end
when 'ed' then
case when country like '%' + @country then 1 else 0 end
when 'ct' then
case when country like '%' + @country +'%' then 1 else 0 end
when 'ne' then
case when country not like @country then 1 else 0 end
end =1
meetdine (User)
Platinum Boarder
Posts: 801
graph
Points: 162420
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2010/03/09 23:29 By meetdine.
The administrator has disabled public write access.
 
#2080
ReSurprisednditional WHERE clauses in T-SQL 1 Year, 11 Months ago Karma: -1
thanks for sharing info..
dayasagar (User)
Platinum Boarder
Posts: 529
graphgraph
Points: 115405
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#2099
ReSurprisednditional WHERE clauses in T-SQL 1 Year, 11 Months ago Karma: 0
thanks for sharing
venkatp (User)
Platinum Boarder
Posts: 334
graphgraph
Points: 135821
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#2255
Re:Conditional WHERE clauses in T-SQL 1 Year, 11 Months ago Karma: 0
thanx
kumarsudu (User)
Senior Boarder
Posts: 79
graphgraph
Points: 55022
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#2932
Re: Conditional WHERE clauses in T-SQL 1 Year, 10 Months ago Karma: 1
Thanks for sharing
surekha.ch20 (User)
Platinum Boarder
Posts: 646
graphgraph
Points: 80521
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#2936
Re:Conditional WHERE clauses in T-SQL 1 Year, 10 Months ago Karma: -1
thanks for sharing info...
dayasagar (User)
Platinum Boarder
Posts: 529
graphgraph
Points: 115405
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 12
Moderators: chandu, harihara.muvvala, usham