Presentation is loading. Please wait.

Presentation is loading. Please wait.

FlowControl i T-SQL

Similar presentations


Presentation on theme: "FlowControl i T-SQL"— Presentation transcript:

1 FlowControl i T-SQL http://www.databasejournal.com/features/mssql/article.php/3361651/Control-of-Flow-with-TSQL.htm http://www.databasejournal.com/features/mssql/article.php/3361651/Control-of-Flow-with-TSQL.htm http://articles.techrepublic.com.com/5100-10878_11-5078041.htmlhttp://articles.techrepublic.com.com/5100-10878_11-5078041.html

2 Kontrolstrukture Sekvens – linje for linje Selektion – IFELSE – CASEWHEN(ELSE) Iteration – GOTO – WHILE

3 Selektion IFELSE – IF EXISTS(SELECT au_fname FROM authors WHERE au_lname = Jones) PRINT 'Found it' ELSE PRINT 'Not Found' – HUSK: BEGIN Hvis der er flere linjer at bruge BEGIN END END RETURN forlader eksempelvis IF

4 Selektion CASE WHEN – CASE WHEN condition THEN trueresult [...n] [ELSE elseresult] END

5 Selektion CASE WHEN – CASE WHEN booleanexpression THEN trueresult [...n] [ELSE elseresult] END

6 Iteration DECLARE @Count int SET @Count = 0 do_it_again: IF @Count < 10 BEGIN PRINT 'Hello World' WAITFOR DELAY '00:00:02' SET @Count = @Count + 1 END IF @Count < 10 GOTO do_it_again

7 Iteration DECLARE @Count int SET @Count = 0 WHILE @Count < 100 BEGIN PRINT 'Hello World' SET @Count = @Count + 1 END

8 Iteration DECLARE @Count int SET @Count = 0 WHILE @Count 10 BREAK ELSE CONTINUE END


Download ppt "FlowControl i T-SQL"

Similar presentations


Ads by Google