Guest User

SQL IF ELSE BEGIN END

a guest
Dec 17th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. IF (a > 1)
  2. SET @b = 1 + 2
  3. INSERT INTO #F (a, b, c) VALUES (1, 2, 3)
  4.  
  5. IF (a > 1)
  6. BEGIN
  7. SET @b = 1 + 2
  8. INSERT INTO #F (a, b, c) VALUES (1, 2, 3)
  9. END
  10.  
  11. IF (a > 1)
  12. BEGIN
  13. SET @b = 1 + 2
  14. INSERT INTO #F (a, b, c) VALUES (1, 2, 3)
  15. END
  16.  
  17. IF (A > 1)
  18. BEGIN
  19. SET @B = 1 + 2
  20. INSERT INTO #F(a, b, c) VALUES (1, 2, 3)
  21. END
  22.  
  23. Declare @a as int
  24. Declare @b as int
  25. Set @a = 2
  26. If (@a > 1) Set @b = 1 + 2 Select 'Select Reached'
  27.  
  28. Declare @a as int
  29. Declare @b as int
  30. Set @a = 2
  31. If (@a > 1)
  32. BEGIN
  33. Set @b = 1 + 2
  34. END
  35. Select 'Select Reached'
  36.  
  37. Declare @a as int
  38. Declare @b as int
  39. Set @a = 1
  40. If (@a > 1) begin Set @b = 1 + 2 end Select 'Select Reached'
  41. if (@a <= 1) begin Set @b = 1 + 2 end Select 'Select not Reached'
Advertisement
Add Comment
Please, Sign In to add comment