TheFan1968

Sybase-SQL case when clause

Jul 13th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DECLARE @current_bind VARCHAR(30)
  2. SET @current_bind = 'tempdb_large_01'
  3. DECLARE @set_tempdb VARCHAR(30)
  4. SET @set_tempdb = 'blub'
  5.  
  6. CASE WHEN @current_bind='tempdb_large_01' THEN SET @set_tempdb = 'tempdb_large_02'
  7.             WHEN @current_bind='tempdb_large_02' THEN SET @set_tempdb = 'tempdb_large_03'
  8.             WHEN @current_bind='tempdb_large_03' THEN SET @set_tempdb = 'tempdb_large_01'
  9.         ELSE SET @set_tempdb = 'blub'
  10.         END
  11.  
  12. print 'current: %1! - set: %2!', @current_bind, @set_tempdb
  13. GO
  14. DECLARE @current_bind VARCHAR(30)
  15. SET @current_bind = 'tempdb_large_01'
  16. DECLARE @set_tempdb VARCHAR(30)
  17. SET @set_tempdb = 'blub'
  18.  
  19. IF @current_bind='tempdb_large_01' BEGIN SET @set_tempdb = 'tempdb_large_02' END
  20. IF @current_bind='tempdb_large_02' BEGIN SET @set_tempdb = 'tempdb_large_03' END
  21. IF @current_bind='tempdb_large_03' BEGIN SET @set_tempdb = 'tempdb_large_01' END
  22.  
  23. print 'current: %1! - set: %2!', @current_bind, @set_tempdb
  24. GO
Add Comment
Please, Sign In to add comment