September 25, 2020
  • 5:49 am Cách cài Win từ ổ cứng: cả Win 7/8/8.1 và Win10 (làm mẫu với Win 10)
  • 2:47 am [Topgame] Top 9 game bắn súng online miễn phí hay nhất đầu 2018 | Android-IOS
  • 8:03 pm Hướng dẫn tạo chú thích footnote trong Word | How to Insert Footnote in Word
  • 7:26 am Cách chèn nhạc vào ảnh và video trên Facebook
  • 6:59 am Tóm Tắt The Walking Dead (Xác Sống) | Season 4



If you’d like to help fund Wise Owl’s conversion of tea and biscuits into quality training videos you can click this link to make a donation. Thanks for watching!

By Andrew Gould

– In SQL Server there is only one type of loop: a WHILE loop. This video teaches you how to use them, from the basic syntax of the WHILE statement, through how to use a SELECT statement within a loop. We’ll also cover how to use the BREAK command to exit from a loop, what to do when you inevitably find yourself in an endless loop and, finally, a quick introduction to using loops with cursors.

You can download the script to create the Movies database used in this video at the following link:

You can see the range of resources and courses we offer in SQL Server here:

Visit www.wiseowl.co.uk for more online training resources in Microsoft Excel, Microsoft Access, Microsoft PowerPoint, Microsoft Word, Microsoft Project, Microsoft Publisher, Microsoft Visio, SQL Server, Reporting Services, Analysis Services, Visual Studio, ASP.NET, VB.NET, C# and more!

Nguồn: https://chaoticpharmacology.com/

Xem thêm bài viết khác: https://chaoticpharmacology.com/cong-nghe/

admin

RELATED ARTICLES

25 COMMENTS

  1. piyush sikka Posted on July 7, 2020 at 6:41 am

    Thank you !
    you videos are very helpful !
    could you please tell me how to go through all rows of one column and print them using loop

    Reply
  2. Ivo Koporcic Posted on July 7, 2020 at 6:41 am

    I needed to learn store procedures, then I was needing everything in this tutorial in this exact order… you deserve the subscribe!

    Reply
  3. hardbrocklife Posted on July 7, 2020 at 6:41 am

    I thought I was going to have to learn Hindi to learn anything about sql lol. Jk…but still.

    Reply
  4. Тимур Курскиев Posted on July 7, 2020 at 6:41 am

    Good one.

    Reply
  5. latinos are hypocrites Posted on July 7, 2020 at 6:41 am

    I know ur a brit but ur english is terrible for a global audience. Im american n i cant tell what ur tryin to say dude. Asians make better sense than u

    Reply
  6. Adi Frenkenberg Posted on July 7, 2020 at 6:41 am

    why did you define the films oscar wins as 'MAX'? Wouldn't it work the same without it?

    Reply
  7. Jesus Ernesto Castelo Estrada Posted on July 7, 2020 at 6:41 am

    wich two films won 11 oscar?? :O

    Reply
  8. Hira Saberi Posted on July 7, 2020 at 6:41 am

    your teaching skill is perfect and your accent is very clear and cute.

    Reply
  9. mahesh sharma Posted on July 7, 2020 at 6:41 am

    HI i have a problem in sql wherein i want to update column value between 10 and 20, there are 100 rows and just want to update next columns between 10 and 20
    can you help me how to figure it out

    Reply
  10. lb33isu Posted on July 7, 2020 at 6:41 am

    Very good videos with clear didactic style. I am a highly experienced Oracle pl/sql programmer who wants to have the skill level to convert to a t-sql programmer since my current employability is bit limited. What experience to you have with Oracle developers becoming t-sql/SQL Server programmers in terms of required effort and success rate in finding SQL Server roles? Thx.

    Reply
  11. Mehmet Huseyin Ozcan Posted on July 7, 2020 at 6:41 am

    Thanks you are the best …. Guys! other way for better solution for seeing 0 film 9 and 10 oscars line
    set @numberFilms = (select COUNT(*) from tblFilm f where f.FilmOscarWins = @count)
    if @numberFilms != 0
    begin
    print cast(@numberFilms as varchar(3)) + ' Films have ' + Cast(@count as varchar(2)) + ' Oscars'
    end

    Reply
  12. Gil De Winter Posted on July 7, 2020 at 6:41 am

    a very good video. clear explanations .rock on

    Reply
  13. Mike Neilson Posted on July 7, 2020 at 6:41 am

    Hi there,

    Enjoying and learning from the video, however, when I downloaded the updated db from the link in the info, running the code in SSMS didn't work and I had to modify the code to get it to work. Below is the code I used

    DECLARE @Counter INT
    DECLARE @MaxFilmOscarWins INT
    DECLARE @NumFilms INT

    SET @MaxFilmOscarWins = (SELECT MAX(FilmOscarWins) FROM [dbo].[tblFilm])
    SET @Counter = 0

    WHILE @Counter<=@MaxFilmOscarWins
    BEGIN
    SET @NumFilms =
    (SELECT COUNT (*) FROM tblFilm WHERE FilmOscarWins = @Counter)

    PRINT CAST(@NumFilms AS VARCHAR(3)) + ' films have won ' +
    CAST(@Counter AS VARCHAR(2)) + ' Oscars. '

    SET @Counter = @Counter + 1
    END

    Hope this helps.

    Mike

    Reply
  14. Estuardo Enrique Juchuña Rosales Posted on July 7, 2020 at 6:41 am

    THANKS BRO …. saved me from a big problem!

    Reply
  15. Common Yunus Posted on July 7, 2020 at 6:41 am

    Your rhetoric is lucid, controlled, non-persuasive and engrossing. A Masterclass. Thanks, Again.

    Reply
  16. Michael O Posted on July 7, 2020 at 6:41 am

    Great tutorial! You sound like a wise owl 🙂 It's very pleasant to the ears.

    Reply
  17. Cristian Melgarejo Posted on July 7, 2020 at 6:41 am

    thanks man!

    Reply
  18. Shahim Khlaifat Posted on July 7, 2020 at 6:41 am

    hello,
    sorry to bother you, but im asking is this how we automate a stored procedure to run automaticlly, it is not working:

    use master
    go
    CREATE PROCEDURE MyBackgroundTask
    AS
    BEGIN
        — SET NOCOUNT ON added to prevent extra result sets from
        — interfering with SELECT statements.
        SET NOCOUNT ON;

        — The interval between cleanup attempts
        declare @timeToRun nvarchar(50)
        set @timeToRun= '03:33:33'

        while 1 = 1
        begin
            waitfor time @timeToRun
            begin
                execute [MyDatabaseName].[dbo].[MyDatabaseStoredProcedure];
            end
        end
    END

    ————

    sp_procoption    @ProcName= 'MyBackgroundTask',
                   @OptionName= 'startup',
                   @OptionValue= 'on'

    Reply
  19. Hjominbonrun Posted on July 7, 2020 at 6:41 am

    This is a good video showing how it works, but you need to start the video stating clearly that a while loop,recursive CTE's and cursors must be done as last resort and only if you have convinced the DBA that there is absolutely no other way.

    Reply
  20. Shahim Khlaifat Posted on July 7, 2020 at 6:41 am

    Yours are very very helpful thank you, but you might ignore the 'print statement' and go for sql database and show the loop in manipulating the data instead. most of the people are not looking to print messages in sql.

    Reply
  21. X Wan Posted on July 7, 2020 at 6:41 am

    Really awl some, I just have a question about the "if ……break" clause, according to the result, the result set will be truncated if @NumFilms=0, but the result for the films that won 11 Oscars is truncated at the same time! We just want to delete the @NumFilms=0 result.  How to solve it?? 

    Reply
  22. Ben Grady Posted on July 7, 2020 at 6:41 am

    Thank you for your very helpful walk-throughs! What software do you use to make your screen capture videos?

    Reply
  23. Marc Johnson Posted on July 7, 2020 at 6:41 am

    One of the clearest explanations I've seen. Well done.

    Reply
  24. krismaly Posted on July 7, 2020 at 6:41 am

    Good introduction of CURSORS. I enjoyed the video. Thanks

    Reply
  25. Rayan Jawad Posted on July 7, 2020 at 6:41 am

    Thanks – you're tutorials are awesome!

    Reply
LEAVE A COMMENT