1

Check '(1=1 AND (1=1 OR 1=1) OR 0=1)' string return true or false

if (1=1 AND (1=1 OR 1=1) OR 0=1)
print '1'
else
print '0'

if i check like this then it returns perfect value but if i have string variable containing value '(1=1 AND (1=1 OR 1=1) OR 0=1)' and then how to check with if clause??

1
  • This isn't SQL syntax. It's probably sql-server specific. You should note that. Commented Nov 7, 2013 at 13:31

1 Answer 1

1

You can build up a dynamic query:

declare @conditionString nvarchar(max)
set @conditionString = '(1=1 AND (1=1 OR 1=1) OR 0=1)'

declare @sql nvarchar(max)
set @sql = 'if ' + @conditionString + '
              print ''1''
            else 
              print ''0'''

sp_executeSql @sql
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.