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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 view with parameters

Author  Topic 

ratcho
Starting Member

18 Posts

Posted - 2002-11-27 : 13:28:47
Simple question:

Is it possible to create view with parameters (the same way like parameters in stored procedures).

For exemple:

Create view MyView
@Date1 as datetime,
@Date2 as datetime
AS
.....

Thanks a lot for your time! Any help will be highly appreciate!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-11-27 : 13:32:51
Nope. Not without using dynamic SQL.

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2002-11-27 : 13:39:08
User-defined functions can do this for you. Look into them, they can be very handy.

That is, with a UDF, you can do:

SELECT * FROM FunctionName(param1, param2) A WHERE A.Field = ...blah blah ...

very handy, which you can't do with stored procs.

I think there are topics in the forum or articles about this somewhere on the website. It can be a little tricky to have a function return a table; i get confused all the time.

- Jeff
Go to Top of Page

ratcho
Starting Member

18 Posts

Posted - 2002-11-27 : 16:41:54
Thanks a lot friends!
You helped me a lot!

Go to Top of Page
   

- Advertisement -