Is the following sectionCode:
If Exists ( Select @ Myvalue = Myvalue From Testtable Where Condition = ' ABC ' )
Begin
Print @ Myvalue
End
When debugging in SSMs, an error is reported:
Message 102 , Level 15 , Status 1 , No 3 Line
' = ' There is a syntax error nearby.
This error should be reported by the equal sign, because the following debugging is performed:
If Exists ( Select 1 From Testtable Where Condition = ' ABC ' )
Begin
Print ' Succeed! '
End
There is no problem, so I am depressed. I directly run the exists content separately, and there is no problem, and there is only one result. After searching for a long time on the Internet, there was no result. It was said that exists and select into had a conflict. I don't know the specific cause.
But fortunately there is still a solution, at least I am not too stupid, the following code can achieve the same effect:
Select @ Myvalue = Myvalue From Testtable Where Condition = ' ABC '
If @ Myvalue Is Not Null
Begin
Print @ Myvalue
End
If any expert knows the reason, give me some guidance.