SQL IF statement is being ignored

前端 未结 2 773
悲&欢浪女
悲&欢浪女 2021-01-22 00:50

I have a long script and I like to be able to just run the whole file when I need to and not worry about if parts of it have already ran. But the script below is giving me probl

2条回答
  •  时光取名叫无心
    2021-01-22 01:16

    I suspect the problem is that one of the columns exist but not both. Try the following:

    IF 2 = (SELECT count(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Notes' AND COLUMN_NAME IN ('EntityId', 'EntityType')) 
    

提交回复
热议问题