Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query -- Help Expand / Collapse
Author
Message
Posted Tuesday, December 17, 2013 7:12 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, April 22, 2016 6:31 AM
Points: 288, Visits: 878
Hi Team,

Please help in below query, it should return TRUE.


DECLARE @req_1 varchar(50)
DECLARE @req_2 varchar(50)

set @req_1='AAM'
set @req_2='VVE'

if (@req_1 !='AAM' OR @req_2 !='VVE')
print 'TRUE'
ELSE
print 'FALSE'

Post #1523674
Posted Tuesday, December 17, 2013 7:32 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Wednesday, April 27, 2016 1:45 PM
Points: 15,549, Visits: 15,699
Minnu (12/17/2013)
Hi Team,

Please help in below query, it should return TRUE.


DECLARE @req_1 varchar(50)
DECLARE @req_2 varchar(50)

set @req_1='AAM'
set @req_2='VVE'

if (@req_1 !='AAM' OR @req_2 !='VVE')
print 'TRUE'
ELSE
print 'FALSE'



What is the business rule you are trying to achieve here? Look at your logic..

Both conditions are false.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1523681
Posted Tuesday, December 17, 2013 10:32 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, January 12, 2016 6:51 AM
Points: 334, Visits: 215
-- Not sure what the Business requirement is but for you to get the output as TRUE, use this:

DECLARE @req_1 varchar(50)
DECLARE @req_2 varchar(50)

set @req_1='AAM'
set @req_2='VVE'

if (@req_1 ='AAM' OR @req_2 ='VVE')
print 'TRUE'
ELSE
print 'FALSE'
Post #1523807
Posted Tuesday, December 17, 2013 10:37 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Wednesday, April 27, 2016 1:45 PM
Points: 15,549, Visits: 15,699
Or maybe this...

if (@req_1 !='AAM' AND @req_2 !='VVE')
print 'TRUE'
ELSE
print 'FALSE'

It all depends on what you are trying to do here.




_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1523810
Posted Wednesday, December 18, 2013 2:56 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 1,714, Visits: 5,882
Minnu (12/17/2013)
Hi Team,

Please help in below query, it should return TRUE.


DECLARE @req_1 varchar(50)
DECLARE @req_2 varchar(50)

set @req_1='AAM'
set @req_2='VVE'

if (@req_1 !='AAM' OR @req_2 !='VVE')
print 'TRUE'
ELSE
print 'FALSE'



It's worth noting that you should replace the non-standard syntax: != with <>.


-- Alan Burstein



Best practices for getting help on SQLServerCentral
Need to split a string? Try DelimitedSplit8K or DelimitedSplit8K_LEAD (SQL 2012+)
Need a pattern-based splitter? Try PatternSplitCM
Need to remove of replace those unwanted characters? Try PatExclude8K and PatReplace8K.

"I can't stress enough the importance of switching from a 'sequential files' mindset to 'set-based' thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code. " -- Itzek Ben-Gan 2001
Post #1524365
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse