Great video, super useful even 10 years later. Is it possible to pass another table (or an array) as an argument? For example, I have a string of values separated by a comma and I would like to perform a clause where particular record contains a value equal to one in my string
Hi! Yes, you can pass tables to parameters providing you use a user-defined table type as described here learn.microsoft.com/en-us/sql/relational-databases/tables/use-table-valued-parameters-database-engine?view=sql-server-ver16 You probably don't need to do that to get the results you need though - you can use the string_split function to split a string into a table. So, for example, you could create a stored procedure like this: create proc usp_FilmsInString @MyString nvarchar(255) as select f.* from dbo.Film as f where f.Title in ( select value from string_split(@MyString, ',') ) and then call the procedure, passing your comma-separated string into it like this: exec usp_FilmsInString @MyString = 'die hard,lethal weapon,twilight' Here's the documentation for the function learn.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-ver16 I hope it helps!
Hi Andrew, great stuff ineed but I have qq: In a 4:42 you select bunch of text and then with one click you move it to the right to have nice structure of the code. Who do you do that? ;)
Very good explanation of ITVF and MSTVF. I think prefixing some characters before function name could identify ITVF and MSTVF may be good practice, since both are stored in the same location. What do you think? Thanks a lot
Awsome overview, even 9 years later. But couldn't you've just used union in the last example? select directorName, directorDOB, 'director' from tblDirector union select actorName, actorDOB, 'actor' from tblActor Thanks for the video
`WHERE YEAR(field) = some_year` is not very good for performance, unless you actually have a computed index on `YEAR(field)`. Instead, it is better to have: `WHERE field >= start_of_year AND field < start_of_next_year`. Nice video, regardless.
I'm watching this 7 years later and I must say this is gold stuff.
It's amazing that people still find them useful after so long! Thanks for watching!
Your videos are far and above anything else available on the subject. Thank you for all your work.
simply AMAZING!! you are AWESOME in explaining concepts
Thanks so much! Happy to hear you're enjoying the videos, thanks for watching!
Many thanks for all 12 parts. I am a starter. These videos explained very well. Thanks again!
Thanks for these videos, really clear and succinct explanations. I really appreciate them!!!
Great video, super useful even 10 years later.
Is it possible to pass another table (or an array) as an argument? For example, I have a string of values separated by a comma and I would like to perform a clause where particular record contains a value equal to one in my string
Hi! Yes, you can pass tables to parameters providing you use a user-defined table type as described here learn.microsoft.com/en-us/sql/relational-databases/tables/use-table-valued-parameters-database-engine?view=sql-server-ver16
You probably don't need to do that to get the results you need though - you can use the string_split function to split a string into a table. So, for example, you could create a stored procedure like this:
create proc usp_FilmsInString
@MyString nvarchar(255)
as
select
f.*
from
dbo.Film as f
where
f.Title in (
select value
from string_split(@MyString, ',')
)
and then call the procedure, passing your comma-separated string into it like this:
exec usp_FilmsInString
@MyString = 'die hard,lethal weapon,twilight'
Here's the documentation for the function learn.microsoft.com/en-us/sql/t-sql/functions/string-split-transact-sql?view=sql-server-ver16
I hope it helps!
Very good explanation, thanks a lot.
Hi Andrew, great stuff ineed but I have qq:
In a 4:42 you select bunch of text and then with one click you move it to the right to have nice structure of the code.
Who do you do that?
;)
Tab.
best sql server videos by far and in clear english. well done. any plans for SSAS videos?
YOU ARE AWESOME!
Great video thanks!
Very good explanation of ITVF and MSTVF.
I think prefixing some characters before function name could identify ITVF and MSTVF may be good practice, since both are stored in the same location. What do you think?
Thanks a lot
Awsome overview, even 9 years later. But couldn't you've just used union in the last example?
select
directorName, directorDOB, 'director'
from
tblDirector
union
select
actorName, actorDOB, 'actor'
from
tblActor
Thanks for the video
You certainly could! As with many things in SQL there's often a variety of ways of achieving the same results!
Nice!!
Thanks!
well explained sir but how to call function from store procedure.?
You are very awesome
why return suffices? shouldn't it be return @t
Does oracle has an equivalent of sqlserver TVF ..??
Hi Simon! A quick Google tells me yes, it does!
@@WiseOwlTutorials thanks, just wondering if you have covered oracle in your series...
@@simonlester4316 Hi Simon! Sorry, no, we don't have any PL/SQL videos.
when I execute the function, it says that 'FilmName etc could not be bound'. Anyone knows why?
Go to edit , intellisense, and refresh local cache
`WHERE YEAR(field) = some_year` is not very good for performance, unless you actually have a computed index on `YEAR(field)`. Instead, it is better to have: `WHERE field >= start_of_year AND field < start_of_next_year`.
Nice video, regardless.
How to calculate networking days in sql?
Networking days = Saturday, sunday and all government holiday
Hi! This link has lots of good suggestions stackoverflow.com/questions/252519/count-work-days-between-two-dates
I hope it helps!
So this is basically working like a stored procedure with a UNION inside of it.
Yes. I meant in this video. Thank you for these videos. They're by far the best I've seen on the subject.