Use function returned value : IF « Transact SQL « SQL Server / T-SQL Tutorial






5>
6>
7>     DECLARE @myresult int
8>     EXEC @myresult = xp_cmdshell "dir c:\tim.txt"
9>     IF (@myresult = 0)
10>         PRINT "Success"
11>     ELSE
12>         PRINT "Failure"
13>     GO
Msg 15281, Level 16, State 1, Server J\SQLEXPRESS, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator c
an enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
Failure








20.7.IF
20.7.1.The syntax of the IF...ELSE statement
20.7.2.Using an Expression with an Explicit Unknown Value
20.7.3.Using an Expression with an Unknown Value Returned from One of the Participating Simple Logical Expressions
20.7.4.Short circuit aborts any further processing of a logical expression as soon as its result can be determined.
20.7.5.IF (@au_id IS NULL)
20.7.6.IF EXISTS
20.7.7.Use function returned value
20.7.8.IF (SELECT ID FROM inserted) like '99[0-9][0-9]'
20.7.9.IF (SELECT COUNT(*) FROM inserted) > 1
20.7.10.If statement with aggregate function
20.7.11.Use if and like to check a pattern
20.7.12.Implementing the ELSE Statement In Our Sproc
20.7.13.A script that tests for outstanding Billings with an IF statement
20.7.14.uses an IF...ELSE statement