Views with variable

Raj0125 511 Reputation points
2022-07-13T21:01:25.26+00:00

Hi,

I need create views with variable as below.

Create view view_name as

Select * from table where tas_id = V_Taskid

V_taskid is variable which are passing during run time from ADF pipeline

Is it possible to pass variable like above in view

Please suggest.

Thanks

Azure SQL Database
Developer technologies Transact-SQL
{count} votes

2 answers

Sort by: Most helpful
  1. Ronen Ariely 15,206 Reputation points
    2022-07-13T23:37:40.56+00:00

    Hi,

    you can use a session Key/Value instead of variable for the task using the function SESSION_CONTEXT

    For full explanation of the limitations and the solution you can check this post:

    https://ariely.info/Blog/tabid/83/EntryId/335/SQL-Server-CREATE-VIEW-which-use-a-Variable.aspx

    ----------

    14150-image.pngRonen Ariely
    Personal Site | Blog | Facebook | Linkedin

    0 comments No comments

  2. Olaf Helper 47,436 Reputation points
    2022-07-14T08:33:33.357+00:00

    I need create views with variable as below.

    You can not use variables in a view, you have to use a stored procedure with a parameter (=variable) instead.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.