SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query -- Help


Query -- Help

Author
Message
Minnu
Minnu
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1401 Visits: 950
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'
Sean Lange
Sean Lange
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64816 Visits: 17979
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 Modens 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)
onlygoodones
onlygoodones
SSC-Addicted
SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)SSC-Addicted (404 reputation)

Group: General Forum Members
Points: 404 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'
Sean Lange
Sean Lange
SSC Guru
SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)SSC Guru (64K reputation)

Group: General Forum Members
Points: 64816 Visits: 17979
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 Modens 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)
Alan.B
Alan.B
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13852 Visits: 8015
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 or 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search