Skip to content
Advertisement

Call tabled function with parameters in sql

I’m a newbie in SQL and with programming languages in general. I’m trying to make a tabled function in SQL (SQL Server):

and then I have to call it in another sql page. I’ve tried to use this syntax:

If I run my SELECT I don’t have any result, because my parameters are not initialized. How can I insert values into them? What I want to do is take values from a table that I’ve created and where I have these attributes and when I run my webpage I’ll fill them.

For example, if I log with ID Session = 1, I’d like to see it into @PAR_id_session and then valorise the other parameters with the user’s choices on the webpage (I have multiple choice for @PAR_days_check_from). How can I do it if I don’t know the values?

Advertisement

Answer

Intialization of variable in T-SQL:

or by using SET:


The function arguments can be populated from table using CROSS/OUTER APPLY:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement