开发者

how to test on variables in sql server triggers?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜