开发者

how to test on variables in sql server triggers?

开发者 https://www.devze.com 2023-04-11 19:38 出处:网络
i need to test if a variable exists in a certain list so i use if @someVar in (\'value1\',\'value2\',\'value3\',)

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号