i need to test if a variable exists in a certain list so i use
if @someVar in ('value1','value2','value3',)
begin
end
but this doesn't work, the body of the if statement is nev开发者_如何学JAVAer executed even if @someVar is equals to a value.
could you help please, thank you very much
That does work there must be some other problem in your code.
declare @someVar varchar(50) = 'value1'
if @someVar in ('value1','value2','value3')
begin
print 'yes'
end
Returns yes
Are you assigning a value to @someVar
? Have you forgotten to give it a length in the variable declaration so it is being silently truncated to 1 character?
精彩评论