Scalar user defined functions in sql server Part 30

Поделиться
HTML-код
  • Опубликовано: 24 июл 2024

Комментарии • 92

  • @wasimbader9170
    @wasimbader9170 8 лет назад +13

    THANK YOU SIR, I HOPE U DO FULL TUT ON SAS/SPSS OR DATA ANALYSIS WITH FEW PROGRAMS

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  8 лет назад +10

      +Wasim Bader Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful.
      At the moment, we don't have videos on the technologies you mentioned. I will record and upload as soon as I can. Thank you very much for your patience.
      Dot Net & SQL Server training videos for web developers
      ruclips.net/user/kudvenkatplaylists?view=1&sort=dd
      You can order DVDs for offline viewing using the link below
      www.pragimtech.com/Order.aspx
      Code Samples & Slides are on my blog
      csharp-video-tutorials.blogspot.com
      Tips to effectively use our channel
      ruclips.net/video/y780MwhY70s/видео.html
      To receive email alerts, when new videos are uploaded, please subscribe to our channel
      ruclips.net/user/kudvenkat
      Please click that THUMBS UP button below the video, if you like the videos
      Thanks a million for sharing these resources with your friends
      Best
      Venkat

  • @ouruzbekhomeschool1334
    @ouruzbekhomeschool1334 Год назад +6

    11 years later, and yet still benefiting from his lessons immensely. Thank you a lot!

  • @lizravenwood5317
    @lizravenwood5317 5 лет назад +7

    I am so in love with your teaching! I cannot believe how brilliant you are with all of these different technologies as well as the ability and willingness to teach and share. Thank you so much. Namaste.

  • @gawiga
    @gawiga 5 лет назад +10

    Your indian accent is so cool.
    Thank you for give this knowledge for free. Greetings from Brazil.

  • @amantlemashele5719
    @amantlemashele5719 4 года назад

    You have been improving my coding since 2015, from C# to MVC to SQL

  • @anuragvashishtha6660
    @anuragvashishtha6660 11 лет назад +3

    I will recommend these videos to every SQL Server student. Thanks a lot Venkat.

  • @devikasiddani
    @devikasiddani 4 года назад

    Hi Venkat, All your videos are simple and clear which makes anyone easy to understand, your tutorials are like a Gift, Thank you so much.

  • @rgarayia
    @rgarayia 8 лет назад

    Hi Venkat, Want to thank you for your wonderful videos. They are simply great!!

  • @tksafi6075
    @tksafi6075 6 лет назад +2

    thanks man your sql videos are the best on youtube

  • @mdfaysal8233
    @mdfaysal8233 5 лет назад

    Thank you Sir for a nice tutorial. All of your tutorials are so much easy to understand for every level of learners.

  • @dbin805
    @dbin805 8 лет назад

    another clear and concise explanation. thanks for this.

  • @vaniagarwal5800
    @vaniagarwal5800 3 года назад +1

    Your videos are just amazing. THANK YOU VERY MUCH SIR.

  • @QuietLumina
    @QuietLumina 4 месяца назад

    This is so incredibly clear and helpful. Thank you so much!

  • @hongshen1702
    @hongshen1702 7 лет назад +1

    Thank you Kudvenkat so much for creating this series of SQL training videos for beginners. They are so easy to understand with the tables and query demonstrations. You are very good at teaching. I learn a few videos each day and decide to finish them all. Again, many thanks.
    Do you teach Python? Hope you have some videos too.

  • @AdrianFusco
    @AdrianFusco 6 лет назад

    Thank you for the video tutorials. You're wonderful.

  • @mdasadujjaman5342
    @mdasadujjaman5342 7 месяцев назад

    12 years later, and still benefiting from his lessons immensely. Thanks a lot Sir.!

  • @nerellapydiraju2320
    @nerellapydiraju2320 10 лет назад

    Very helpful videos for beginners, Thank you very much

  • @RPTech-ic2ed
    @RPTech-ic2ed 8 лет назад +1

    very help full stuff, great job

  • @yamaya5136
    @yamaya5136 2 года назад

    Watching you in 2022. Your teaching style is very easy to grasp. God bless!

  • @Csharp-video-tutorialsBlogspot
    @Csharp-video-tutorialsBlogspot  11 лет назад +2

    Hi zainzoom,
    To invoke a scalar function prefix dbo. before the name of the function. For example, if you have order with Id=101, then invoke the function as shown below.
    Select dbo.GetTotalOrderValue(201), SomeOtherColumn
    from SomeTable
    where SomeCondition
    I hope this will resolve your issue. If not let me know.

  • @pucca9090
    @pucca9090 10 лет назад

    I love your session so much. Thanks for help me

  • @maheshgore1066
    @maheshgore1066 3 года назад

    Great session...very informative and complete

  • @daliladali1268
    @daliladali1268 7 лет назад

    thank you very much sir,very good explanation

  • @brahmanathtripathi2213
    @brahmanathtripathi2213 10 лет назад

    Hi Venkat, Your video help me a lot. I like all your video. A small request this video blur some part so that not clearly visible of creating function so please upload again with good visibility

  • @kaushikbhadani
    @kaushikbhadani 10 лет назад

    thanks Venkat... really very very post..

  • @prabdeepdhaliwal9725
    @prabdeepdhaliwal9725 3 года назад +5

    So I was trying to create the CalculateAge() function myself and display the table with Name, DOB and Age before you showed us how to. I got the age values that were 10 years higher than your values and was confused on what I did wrong. Then I remembered the video is like 10 years old so all those people aged by 10 😂

  • @ishwakv1171
    @ishwakv1171 2 года назад

    Thank you sir.. U r way teaching superb sir...

  • @naodagere8210
    @naodagere8210 4 года назад

    You are exceptional!

  • @Idhikapabi
    @Idhikapabi 9 лет назад +1

    Thanku sir... your are really great teacher.I want to meet you Sir & say many many thnx^^.... Sir please upload AJAX tutorials....

  • @danielofosuasare7757
    @danielofosuasare7757 7 лет назад

    good work done, very useful

  • @xswooshx
    @xswooshx 6 лет назад

    Thanks for the video! Just became a subscriber.
    Question: Is it possible to create a function in a 'general' location so that it can be called from any database that you might be using?

  • @ahsansiddiqui4263
    @ahsansiddiqui4263 7 лет назад +1

    Tony the Tigerrrr: "This is Grrrreat!"

  • @sarathchandhra1284
    @sarathchandhra1284 10 лет назад

    nice explanation thanks venkat

  • @gauranshbhutani592
    @gauranshbhutani592 3 года назад

    I really like your way of teaching.....Can you please provide a SAS tutorial basic to advanced??

  • @Nadeeraasanka
    @Nadeeraasanka 10 лет назад

    thanks for help.....I learn something ..:D

  • @MO-er7xp
    @MO-er7xp 4 года назад

    you are the best bro thank you

  • @nandadk314
    @nandadk314 6 лет назад

    Hi Sir, you said the returned value can not be of cursor.. But we are using a function and returning p_recordset which is a sys ref cursor.. can you explain... my function is as below:
    Create or replace Function fn_name (v_param in varchar2)
    Return sys_refcursor as p_recordset sys_refcursor;
    Begin
    Open
    OPEN p_recordset FOR
    SELECT
    FROM
    WHERE
    WHERE
    (V1."param" = V_param);
    RETURN p_recordset;
    END;

  • @DriveWithMunna
    @DriveWithMunna 5 лет назад

    just excellent sir

  • @The_Alco
    @The_Alco 5 лет назад +20

    SQUARE, BRING ME MY SWORD.

  • @krismaly6300
    @krismaly6300 9 лет назад +1

    Thanks

  • @gracechan3039
    @gracechan3039 4 года назад +1

    In Korea that actually count you as 1 year old as soon as you are born, so Koreans didn't need to add the case statement. haha.
    Seriously though, thanks for these videos. They help me so much with my job.

  • @neo77jb
    @neo77jb 10 лет назад

    Great, thanx

  • @deepro__
    @deepro__ Год назад

    Thank you, sir.

  • @RudraPratapSinghLearning
    @RudraPratapSinghLearning 7 лет назад

    Awesom Video, Please tell that is there any performance issue with functions in comparison to procedures?

  • @kirannadukula5247
    @kirannadukula5247 11 лет назад +1

    Hi, venkat could you please make videos on AJAX Controls. I watched a lot of videos but could not understand any of them because they are not a match to the way you explain. So, please make some videos on Ajax controls venkat. I request please...................

  • @omotayoogunnika6865
    @omotayoogunnika6865 Год назад

    Thanks for this tutorial. Can you please explain the logic behind subtracting 1 from DATEDIFF(YEAR, DOB, GETDATE)) ) when the conditions are met. Thanks..

  • @evvavinash
    @evvavinash 8 лет назад +2

    +kudvenkat, you created the function called CalculateAge and said that we can call this function in future to calculate the age. How different is it from creating a stored procedure for calculating the age and using this stored procedure to calculate the age?

    • @saurabhs4743
      @saurabhs4743 8 лет назад +1

      +sai avinash edara the function can be used as a new column while stored procedure wont do that

    • @SuperGojeto
      @SuperGojeto 8 лет назад +1

      +sai avinash edara if you watched his videos carefully then you will find out he has explained the difference.

  • @soniasadeque5950
    @soniasadeque5950 7 лет назад

    can you give me the name of a good SQL book for databse testing? thanks for your videos Sir

  • @Superman-hr4xl
    @Superman-hr4xl 10 лет назад

    Venkat, this video on your Calculating Age Function is so Advanced and Essential. Will you (can you please make) be making a mini misc. tutorials on advanced topic such as this?

    • @artokilponen6989
      @artokilponen6989 7 лет назад +1

      If someone else (since this question is three years old) has same problem with programming, remember that you should take these in pieces, not swallow as whole at once. In this case, make sure you understand CASE-WHEN-THEN-ELSE-END first and then advance from there.

  • @freddylouza7874
    @freddylouza7874 8 лет назад

    very helpful

  • @amitkishor7338
    @amitkishor7338 7 лет назад +3

    make a video for different between stored procedure and function it a very important question in an interview

    • @artokilponen6989
      @artokilponen6989 7 лет назад +2

      Check this one to begin with: stackoverflow.com/questions/2039936/difference-between-stored-procedures-and-user-defined-functions
      Procedure can return zero or n values whereas function can return one value which is mandatory.
      Procedures can have input/output parameters for it whereas functions can have only input parameters.
      Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
      Functions can be called from procedure whereas procedures cannot be called from function.
      Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
      We can go for transaction management in procedure whereas we can't go in function.
      Procedures can not be utilized in a select statement whereas function can be embedded in a select statement.
      UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be.
      UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
      Inline UDF's can be though of as views that take parameters and can be used in JOINs and other Rowset operations.

  • @rdg515
    @rdg515 10 лет назад +2

    I guess my real question is, when should you use output parameters vs functions?

  • @shikhilbhalla969
    @shikhilbhalla969 4 года назад

    Why we are using .dbo as prefix in scalar user defined function? What is the reason behind this?

  • @honzekpavlicek4044
    @honzekpavlicek4044 10 лет назад

    Nice video and explanation is great. Thx...but you can get example not about data or date of birth...:-)

  • @rdg515
    @rdg515 10 лет назад

    Couldn't you have used spCalculateAge if you had created an output parameter?

  • @santhoshzany1451
    @santhoshzany1451 2 года назад

    I'm not able to run this function. Can not find column or user defined function or aggregate or name ambiguous.
    Please answer

  • @tarikzaman9096
    @tarikzaman9096 2 года назад

    Happy birthday !

  • @EmpoweringPerson
    @EmpoweringPerson 4 года назад

    Thanx

  • @dattatrayarathi1014
    @dattatrayarathi1014 4 года назад

    How do I calculate age in year and month and date format?

  • @mshahzeb8926
    @mshahzeb8926 4 года назад

    what is the difference between functions and stored procedure.

  • @aamirali8114
    @aamirali8114 2 года назад

    I am getting an error in the first line in @DOB Date of Create Function CalculateAge(@DOB Date), even I am getting an error when I using declare keyword: is not valid position, expecting.

  • @kinjalthumar814
    @kinjalthumar814 3 года назад

    I WRITE SAME QUERY TO CREATE FUNCTION IN MY LAPTOP SSMS BUT NOT ABLE TO CREATE FUNCTION PLEASE SIR CAN YOU EXPLAIN MORE THANK YOU

  • @santoshdachepalli
    @santoshdachepalli 10 лет назад

    great!!!!!!!!!!!!!!1

  • @adityasamanta8621
    @adityasamanta8621 10 лет назад

    I am trying to write a function that spits out a random number. - basically I have a table in which I want to add a column with has random numbers assigned to each record
    Create Function fnRand()
    returns int
    as
    begin
    declare @num as int
    set @num= round(rand()*100,0)
    Return @num
    end
    I am getting the following error : please can you help:
    Msg 443, Level 16, State 1, Procedure fnRand, Line 7
    Invalid use of a side-effecting operator 'rand' within a function.

    • @hellofriend2012
      @hellofriend2012 9 лет назад

      I think you cannot use RAND() function in user-defined functions

    • @archrodney
      @archrodney 9 лет назад

      Aditya Samanta You could just use built-in functions like this:
      select MyColumnList, abs(checksum(newid())) % 100 as [Random numbers] from MyTable
      OR
      select MyColumnList, cast(rand(checksum(newid())) * 100 as int) + 1 as [Random numbers] from MyTable

  • @Amritha8
    @Amritha8 9 лет назад

    Hi Venkat - Can you please write a function to find the number of Sundays in a month when you pass a date value?

    • @zackziss
      @zackziss 8 лет назад +2

      Hi Amritha, PFB script ALTER FUNCTION
      --ALTER PROC
      fn_SundayCount(@dtDate DATE)
      RETURNS INT
      AS
      BEGIN
      DECLARE @Count INT, @StartOfMonth DATE, @EndOfMonth INT, @MonthNo INT, @YearNo INT
      SET @Count = 0
      SET @EndOfMonth = 0
      SET @MonthNo = DATEPART(MM, @dtDate)
      SET @YearNo = DATEPART(YYYY, @dtDate)
      SET @StartOfMonth = CONVERT(DATE, CONVERT(CHAR(4), @YearNo) + '-' + CONVERT(VARCHAR(2), @MonthNo) + '-01')
      --SELECT CONVERT(CHAR(2), @MonthNo) AS [MonthNo], CONVERT(CHAR(4), @YearNo) AS [YearNo], @StartOfMonth AS [StartOfMonth]
      --PRINT @StartOfMonth
      IF @MonthNo = 2
      BEGIN
      IF (@YearNo % 4) = 0
      SET @EndOfMonth = 29
      ELSE
      SET @EndOfMonth = 28
      END
      ELSE IF @MonthNo >= 8
      BEGIN
      IF (@MonthNo % 2) = 0
      SET @EndOfMonth = 31
      ELSE
      SET @EndOfMonth = 30
      END
      ELSE
      BEGIN
      IF (@MonthNo % 2) = 1
      SET @EndOfMonth = 31
      ELSE
      SET @EndOfMonth = 30
      END
      WHILE (DATEPART(DD, @StartOfMonth)

    • @devexpost8508
      @devexpost8508 7 лет назад +1

      Amritha S / zackziss,
      When finding number of Sundays in a month, the days of the month from 01 --> 28 will ALWAYS be 28 days, and will always contain 4 Sundays, no matter what. For your solution, start looping from day 29 instead of day 01 and save yourself 28 unnecessary WHILE Loop iterations on each procedure invocation...
      *Instead of doing this:*
      SET @Count = 0
      ...
      SET @StartOfMonth = CONVERT(DATE, CONVERT(CHAR(4), @YearNo) + '-' + CONVERT(VARCHAR(2), @MonthNo) + '-01')
      *do this:*
      SET @Count = 4
      ...
      SET @StartOfMonth = CONVERT(DATE, CONVERT(CHAR(4), @YearNo) + '-' + CONVERT(VARCHAR(2), @MonthNo) + '-29')
      Best Regards.

  • @SimpleScratch9
    @SimpleScratch9 4 года назад

    Hi Sir, I would like to take Microsoft 70-761 Exam. Just advise me how to pass the exam.

  • @shashankpulijala3378
    @shashankpulijala3378 8 лет назад +1

    Can we give two parameters to a function?

  • @saniyasaleem6434
    @saniyasaleem6434 5 месяцев назад

    Sir can u upload SSRS and SSIS pls

  • @variniaquisbert4212
    @variniaquisbert4212 4 года назад +1

    Why do you use "dbo." before a function's name? What's dbo? Is a database name?

    • @tanaygupta5133
      @tanaygupta5133 4 года назад

      DBO(database owner) full form. It is a schema name usually we use before table name or fumctions.

  • @sudhapandian6577
    @sudhapandian6577 7 лет назад

    I GOT ERROR // Conversion failed when converting date and/or time from character string.///

  • @souravkundu7051
    @souravkundu7051 6 месяцев назад

    😊

  • @stutitehri993
    @stutitehri993 10 лет назад

    good videos,however, fonts for sql server appears to be small;hence less viewable

  • @penchalababuallam2717
    @penchalababuallam2717 3 года назад

    Please share sample database

  • @Creator07-sx2gl
    @Creator07-sx2gl 2 года назад

    can we please connect? I need help in one problem..please if you need this comment do connect once

  • @coding3438
    @coding3438 2 года назад

    instead of case statement:
    declare @dob date
    declare @age int
    set @dob = '2021-08-28'
    select datediff(month,@dob,getdate())/12

  • @c-jay8500
    @c-jay8500 4 года назад