检查'(1 = 1 AND(1 = 1 OR 1 = 1)或0 = 1)'字符串返回true或false
if (1=1 AND (1=1 OR 1=1) OR 0=1)
print '1'
else
print '0'
如果我这样检查那么它返回完美值但是如果我有字符串变量包含值'(1 = 1 AND(1 = 1 OR 1 = 1)或0 = 1)'然后如何检查if子句??
答案 0 :(得分:1)
您可以构建动态查询:
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