Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 parametric sql

Author  Topic 

casati74
Posting Yak Master

109 Posts

Posted - 2007-01-31 : 05:56:54
It is possible pass a parameter to a view????


es:


create view test

@var1
@var 2

select * from table 1
where column1 = @var1 and column2 = @var2
union all
select * from table 2
where column1 = @var1 and column2 = @var2
union all
..........



Thank's

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-31 : 06:00:22
No.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-01-31 : 06:13:32
But you can create Inline table valued function to do this:

Create Function test
(@var1 varchar(10), @var2 varchar(10))
Returns Table
as
Return(Select * from table1 where col1 = @var1 and col2 = @var2
union all
...
)


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

casati74
Posting Yak Master

109 Posts

Posted - 2007-01-31 : 06:20:49
Ok also for me the functions is the only one solution!!!

But i spoke with one people that ha said me there is a possible to create a parametric view!!!

Thank's
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-01-31 : 06:28:11
he told you wrong.



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -