Udf&views in sql...by thanveer melayi
-
Upload
muhammed-thanveer-danish-melayi -
Category
Software
-
view
24 -
download
2
description
Transcript of Udf&views in sql...by thanveer melayi
![Page 1: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/1.jpg)
![Page 2: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/2.jpg)
UDF &VIEWSIN SQL
Muhammed Tanveer [email protected] Thanveer Danish MelayiMuhammed Thanveer. MLinkedin Profile
TYPING SPEED:25
![Page 3: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/3.jpg)
Disclaimer: This presentation is prepared by trainees of baabtra.com as a part of mentoring program. This is not official document of baabtra.com – Mentoring Partner
![Page 4: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/4.jpg)
UDFThere are three Types of UDFS in Sql Server:1. Scalar
2. Inline Table-Valued
3. Multi-statement Table-Valued
• It can be used with SQL select queries same like we use any other scalar or aggregate functions that we discussed earlier(eg :sum(),Avg()ect)
• UDF must return value
![Page 5: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/5.jpg)
Scalar User-Defined FunctionA Scalar UDF can accept 0 to many input parameter and will return a single value. A Scalar user-defined function returns one of the scalar (int, char, varchar etc) data types. Text, ntext, image and timestamp data types are not supported.
exampleCREATE FUNCTION AddTwoNumbers(@a int,@b int)RETURNS intASBEGINRETURN @a + @bENDSELECT dbo.AddTwoNumbers(30,20)
![Page 6: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/6.jpg)
Table-valued functionsA table-valued UDF is a function that accepts parameters and returns the results in the form of a table. This type of function is special because it returns a table that you can query the results of and join with other tables
![Page 7: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/7.jpg)
example CREATE FUNCTION GetAllProducts( )RETURNS TABLEASRETURN(SELECT ProductID, ProductName, RetailPrice, CategoryFROM CurrentProducts)GO
![Page 8: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/8.jpg)
VIEWS • A view is a customized representation of data from one
or more tables.The table that the view is referencing are known as base table
• A view can be considered as a stored query or virtual table
• View Doesn’t take any storage space
![Page 9: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/9.jpg)
syntaxCREATE VIEW view_name AS SELECT column_name(s) FROM table_name WHERE condition
example CREATE VIEW [Current Product List] ASSELECT ProductID,ProductNameFROM ProductsWHERE Discontinued=No
![Page 10: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/10.jpg)
Views - Advantages• Data Security No need to give permission on the table.infact a view can be created,having only selected • Simplicity A very complicated query can be saved as a view definition.When needed can be called by its view name • Removes Dependency Can be very helpful to remove the dependency from the underlying tables.suppose a view is created join servel tables
![Page 11: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/11.jpg)
thank you
![Page 12: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/12.jpg)
Want to learn more about programming or Looking to become a good programmer?
Are you wasting time on searching so many contents online?
Do you want to learn things quickly?
Tired of spending huge amount of money to become a Software professional?
Do an online course @ baabtra.com
We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
![Page 13: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/13.jpg)
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
![Page 14: Udf&views in sql...by thanveer melayi](https://reader036.fdocuments.us/reader036/viewer/2022082808/55620a88d8b42acb1e8b46f3/html5/thumbnails/14.jpg)
Emarald Mall (Big Bazar Building)Mavoor Road, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
NC Complex, Near Bus StandMukkam, Kozhikode,Kerala, India.Ph: + 91 – 495 40 25 550
Cafit Square,Hilite Business Park,Near Pantheerankavu,Kozhikode
Start up VillageEranakulam,Kerala, India.Email: [email protected]
Contact Us