我正在做一个IF声明,想要一个完全匹配.
IF ( @a_Action <> 'Power On' AND @a_Action <> 'Power Off' AND @a_Action <> 'Reset' )
BEGIN
-- Invalid action - an IPMI command.
-- Set call as failed.
SELECT @ErrorSw = 'Y'
SELECT @ApiResultOut = 0
SELECT @ApiResultCodeOut = 1610
SELECT @ApiMessageOut = 'Warning - action type "' + @a_Action + '" is not a valid server (IPMI) command.'
END
Run Code Online (Sandbox Code Playgroud)
如果@a_Action参数作为"开机"发送,它将通过而不是错误输出.只有完全匹配才能通过.
DECLARE @a_Action VARCHAR(20)
SET @a_Action = 'Power on' COLLATE SQL_Latin1_General_CP1_CS_AS
IF (@a_Action = 'Power On' COLLATE SQL_Latin1_General_CP1_CS_AS)
PRINT 'match'
ELSE
PRINT 'not match'
Run Code Online (Sandbox Code Playgroud)